njn | c953984 | 2002-10-02 13:26:35 +0000 | [diff] [blame] | 1 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Higher-level UCode sequence builders ---*/ |
| 4 | /*--- vg_instrument.c ---*/ |
| 5 | /*--------------------------------------------------------------------*/ |
| 6 | |
| 7 | /* |
njn | c953984 | 2002-10-02 13:26:35 +0000 | [diff] [blame] | 8 | This file is part of Valgrind, an extensible x86 protected-mode |
| 9 | emulator for monitoring program execution on x86-Unixes. |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 10 | |
| 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 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 42 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 43 | void VG_(call_helper_0_0)(UCodeBlock* cb, Addr f) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 44 | { |
| 45 | uInstr0(cb, CCALL, 0); |
| 46 | uCCall(cb, f, 0, 0, 0); |
| 47 | } |
| 48 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 49 | void VG_(call_helper_1_0)(UCodeBlock* cb, Addr f, UInt arg1, UInt regparms_n) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 50 | { |
| 51 | UInt t1 = newTemp(cb); |
| 52 | |
njn | e427a66 | 2002-10-02 11:08:25 +0000 | [diff] [blame] | 53 | sk_assert(regparms_n <= 1); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 54 | 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 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 60 | void VG_(call_helper_2_0)(UCodeBlock* cb, Addr f, UInt arg1, UInt arg2, |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 61 | UInt regparms_n) |
| 62 | { |
| 63 | UInt t1 = newTemp(cb); |
| 64 | UInt t2 = newTemp(cb); |
| 65 | |
njn | e427a66 | 2002-10-02 11:08:25 +0000 | [diff] [blame] | 66 | sk_assert(regparms_n <= 2); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 67 | 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 | |
| 75 | void 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 | |
njn | 6fefa1b | 2003-02-24 10:32:51 +0000 | [diff] [blame^] | 87 | void 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 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 96 | /*--------------------------------------------------------------------*/ |
| 97 | /*--- end vg_instrument.c ---*/ |
| 98 | /*--------------------------------------------------------------------*/ |
| 99 | |