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 | |
njn | 0e1b514 | 2003-04-15 14:58:06 +0000 | [diff] [blame] | 11 | Copyright (C) 2000-2003 Nicholas Nethercote |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 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 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 32 | /* 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 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 38 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 39 | void VG_(call_helper_0_0)(UCodeBlock* cb, Addr f) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 40 | { |
| 41 | uInstr0(cb, CCALL, 0); |
| 42 | uCCall(cb, f, 0, 0, 0); |
| 43 | } |
| 44 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 45 | 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] | 46 | { |
| 47 | UInt t1 = newTemp(cb); |
| 48 | |
njn | e427a66 | 2002-10-02 11:08:25 +0000 | [diff] [blame] | 49 | sk_assert(regparms_n <= 1); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 50 | 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 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 56 | 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] | 57 | UInt regparms_n) |
| 58 | { |
| 59 | UInt t1 = newTemp(cb); |
| 60 | UInt t2 = newTemp(cb); |
| 61 | |
njn | e427a66 | 2002-10-02 11:08:25 +0000 | [diff] [blame] | 62 | sk_assert(regparms_n <= 2); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 63 | 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 | |
| 71 | void 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 | |
njn | 6fefa1b | 2003-02-24 10:32:51 +0000 | [diff] [blame] | 83 | void 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 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 92 | /*--------------------------------------------------------------------*/ |
| 93 | /*--- end vg_instrument.c ---*/ |
| 94 | /*--------------------------------------------------------------------*/ |
| 95 | |