本文在CSDN的地址:点这里
tcg/tcg.h:
Define type and accessor macros for TCG variables.
TCG variables are the inputs and outputs of TCG ops, as described
in tcg/README. Target CPU front-end code uses these types to deal
with TCG variables as it emits TCG code via the tcggen* functions.
They come in several flavours:
- TCGv_i32 : 32 bit integer type
- TCGv_i64 : 64 bit integer type
- TCGv_ptr : a host pointer type
- TCGv_vec : a host vector type; the exact size is not exposed
to the CPU front-end code. - TCGv : an integer type the same size as target_ulong
(an alias for either TCGv_i32 or TCGv_i64)
The compiler’s type checking will complain if you mix them
up and pass the wrong sized TCGv to a function.
Users of tcggen* don’t need to know about any of the internal
details of these, and should treat them as opaque types.
You won’t be able to look inside them in a debugger either.
Internal implementation details follow:
Note that there is no definition of the structs TCGv_i32_d etc anywhere.
This is deliberate, because the values we store in variables of type
TCGv_i32 are not really pointers-to-structures. They’re just small
integers, but keeping them in pointer types like this means that the
compiler will complain if you accidentally pass a TCGv_i32 to a
function which takes a TCGv_i64, and so on. Only the internals of
TCG need to care about the actual contents of the types.
tcg/optimize.c
static TCGArg do_constant_folding_2(TCGOpcode op, TCGArg x, TCGArg y)
{
uint64_t l64, h64;
switch (op) {
CASE_OP_32_64(add):
return x + y;
CASE_OP_32_64(sub):
return x - y;
CASE_OP_32_64(mul):
return x * y;
CASE_OP_32_64(and):
return x & y;
CASE_OP_32_64(or):
return x | y;
CASE_OP_32_64(xor):
return x ^ y;
case INDEX_op_shl_i32:
return (uint32_t)x << (y & 31);
可以看到TCGV就是普通的操作数
近期评论