blob: 46bbc696d2cd684c57dcac690c7b5b4728a45dd1 [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
njn0e1b5142003-04-15 14:58:06 +000011 Copyright (C) 2000-2003 Nicholas Nethercote
njn25e49d8e72002-09-23 09:36:25 +000012 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
njn25e49d8e72002-09-23 09:36:25 +000032/* We only import vg_skin.h here, because this file only provides functions
33 for doing things that could be done directly by the skin -- it's just to
34 make skins' lives easier, rather than let them do something they
35 couldn't otherwise do. */
36#include "vg_skin.h"
37
njn25e49d8e72002-09-23 09:36:25 +000038
njn4ba5a792002-09-30 10:23:54 +000039void VG_(call_helper_0_0)(UCodeBlock* cb, Addr f)
njn25e49d8e72002-09-23 09:36:25 +000040{
41 uInstr0(cb, CCALL, 0);
42 uCCall(cb, f, 0, 0, 0);
43}
44
njn4ba5a792002-09-30 10:23:54 +000045void VG_(call_helper_1_0)(UCodeBlock* cb, Addr f, UInt arg1, UInt regparms_n)
njn25e49d8e72002-09-23 09:36:25 +000046{
47 UInt t1 = newTemp(cb);
48
njne427a662002-10-02 11:08:25 +000049 sk_assert(regparms_n <= 1);
njn25e49d8e72002-09-23 09:36:25 +000050 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t1);
51 uLiteral(cb, arg1);
52 uInstr1(cb, CCALL, 0, TempReg, t1);
53 uCCall(cb, f, 1, regparms_n, 0);
54}
55
njn4ba5a792002-09-30 10:23:54 +000056void VG_(call_helper_2_0)(UCodeBlock* cb, Addr f, UInt arg1, UInt arg2,
njn25e49d8e72002-09-23 09:36:25 +000057 UInt regparms_n)
58{
59 UInt t1 = newTemp(cb);
60 UInt t2 = newTemp(cb);
61
njne427a662002-10-02 11:08:25 +000062 sk_assert(regparms_n <= 2);
njn25e49d8e72002-09-23 09:36:25 +000063 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t1);
64 uLiteral(cb, arg1);
65 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t2);
66 uLiteral(cb, arg2);
67 uInstr2(cb, CCALL, 0, TempReg, t1, TempReg, t2);
68 uCCall(cb, f, 2, regparms_n, 0);
69}
70
71void VG_(set_global_var)(UCodeBlock* cb, Addr globvar_ptr, UInt val)
72{
73 Int t_gv = newTemp(cb);
74 Int t_val = newTemp(cb);
75
76 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t_val);
77 uLiteral(cb, val);
78 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t_gv);
79 uLiteral(cb, globvar_ptr);
80 uInstr2(cb, STORE, 4, TempReg, t_val, TempReg, t_gv);
81}
82
njn6fefa1b2003-02-24 10:32:51 +000083void VG_(set_global_var_tempreg)(UCodeBlock* cb, Addr globvar_ptr, UInt t_val)
84{
85 Int t_gv = newTemp(cb);
86
87 uInstr2(cb, MOV, 4, Literal, 0, TempReg, t_gv);
88 uLiteral(cb, globvar_ptr);
89 uInstr2(cb, STORE, 4, TempReg, t_val, TempReg, t_gv);
90}
91
njn25e49d8e72002-09-23 09:36:25 +000092/*--------------------------------------------------------------------*/
93/*--- end vg_instrument.c ---*/
94/*--------------------------------------------------------------------*/
95