blob: 6bb425f92bff0cf37e5e1aa0df6200bfa7684230 [file] [log] [blame]
njnc9539842002-10-02 13:26:35 +00001
njn25e49d8e72002-09-23 09:36:25 +00002/*--------------------------------------------------------------------*/
3/*--- Higher-level UCode sequence builders ---*/
4/*--- vg_instrument.c ---*/
5/*--------------------------------------------------------------------*/
6
7/*
njnc9539842002-10-02 13:26:35 +00008 This file is part of Valgrind, an extensible x86 protected-mode
9 emulator for monitoring program execution on x86-Unixes.
njn25e49d8e72002-09-23 09:36:25 +000010
11 Copyright (C) 2000-2002 Nicholas Nethercote
12 njn25@cam.ac.uk
13
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation; either version 2 of the
17 License, or (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 02111-1307, USA.
28
29 The GNU General Public License is contained in the file COPYING.
30*/
31
32// SSS: should this file should eventually not be in core, but included in
33// skins that use it?? Reduces size of core, but increases size of every
34// skin that uses it...
35
36/* We only import vg_skin.h here, because this file only provides functions
37 for doing things that could be done directly by the skin -- it's just to
38 make skins' lives easier, rather than let them do something they
39 couldn't otherwise do. */
40#include "vg_skin.h"
41
njn25e49d8e72002-09-23 09:36:25 +000042
njn4ba5a792002-09-30 10:23:54 +000043void VG_(call_helper_0_0)(UCodeBlock* cb, Addr f)
njn25e49d8e72002-09-23 09:36:25 +000044{
45 uInstr0(cb, CCALL, 0);
46 uCCall(cb, f, 0, 0, 0);
47}
48
njn4ba5a792002-09-30 10:23:54 +000049void VG_(call_helper_1_0)(UCodeBlock* cb, Addr f, UInt arg1, UInt regparms_n)
njn25e49d8e72002-09-23 09:36:25 +000050{
51 UInt t1 = newTemp(cb);
52
njne427a662002-10-02 11:08:25 +000053 sk_assert(regparms_n <= 1);
njn25e49d8e72002-09-23 09:36:25 +000054 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t1);
55 uLiteral(cb, arg1);
56 uInstr1(cb, CCALL, 0, TempReg, t1);
57 uCCall(cb, f, 1, regparms_n, 0);
58}
59
njn4ba5a792002-09-30 10:23:54 +000060void VG_(call_helper_2_0)(UCodeBlock* cb, Addr f, UInt arg1, UInt arg2,
njn25e49d8e72002-09-23 09:36:25 +000061 UInt regparms_n)
62{
63 UInt t1 = newTemp(cb);
64 UInt t2 = newTemp(cb);
65
njne427a662002-10-02 11:08:25 +000066 sk_assert(regparms_n <= 2);
njn25e49d8e72002-09-23 09:36:25 +000067 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t1);
68 uLiteral(cb, arg1);
69 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t2);
70 uLiteral(cb, arg2);
71 uInstr2(cb, CCALL, 0, TempReg, t1, TempReg, t2);
72 uCCall(cb, f, 2, regparms_n, 0);
73}
74
75void VG_(set_global_var)(UCodeBlock* cb, Addr globvar_ptr, UInt val)
76{
77 Int t_gv = newTemp(cb);
78 Int t_val = newTemp(cb);
79
80 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t_val);
81 uLiteral(cb, val);
82 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t_gv);
83 uLiteral(cb, globvar_ptr);
84 uInstr2(cb, STORE, 4, TempReg, t_val, TempReg, t_gv);
85}
86
njn6fefa1b2003-02-24 10:32:51 +000087void VG_(set_global_var_tempreg)(UCodeBlock* cb, Addr globvar_ptr, UInt t_val)
88{
89 Int t_gv = newTemp(cb);
90
91 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t_gv);
92 uLiteral(cb, globvar_ptr);
93 uInstr2(cb, STORE, 4, TempReg, t_val, TempReg, t_gv);
94}
95
njn25e49d8e72002-09-23 09:36:25 +000096/*--------------------------------------------------------------------*/
97/*--- end vg_instrument.c ---*/
98/*--------------------------------------------------------------------*/
99