This adds:

INSN_MOV_IMM_THREAD_LOCAL_MEMBASE,
INSN_MOV_REG_THREAD_LOCAL_MEMBASE,
INSN_MOV_REG_THREAD_LOCAL_MEMDISP

Those will be needed for selecting code for storing information
into JNI and VM native call stack entries.

Signed-off-by: Tomek Grabiec <[email protected]>
---
 arch/x86/emit-code.c                |   32 ++++++++++++++++++++++++
 arch/x86/include/arch/instruction.h |    3 ++
 arch/x86/lir-printer.c              |   45 +++++++++++++++++++++++++++++++++++
 arch/x86/use-def.c                  |    3 ++
 4 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c
index 1997526..f3a0485 100644
--- a/arch/x86/emit-code.c
+++ b/arch/x86/emit-code.c
@@ -473,6 +473,11 @@ int fixup_static_at(unsigned long addr)
  * x86-32 code emitters *
  ************************/
 
+static void emit_mov_reg_membase(struct buffer *buf, struct operand *src,
+                                struct operand *dest);
+static void emit_mov_imm_membase(struct buffer *buf, struct operand *src,
+                                struct operand *dest);
+
 /*
  *     __encode_reg:   Encode register to be used in IA-32 instruction.
  *     @reg: Register to encode.
@@ -724,6 +729,30 @@ static void emit_mov_thread_local_memdisp_reg(struct 
buffer *buf,
        __emit_memdisp_reg(buf, 0x8b, src->imm, mach_reg(&dest->reg));
 }
 
+static void emit_mov_reg_thread_local_memdisp(struct buffer *buf,
+                                             struct operand *src,
+                                             struct operand *dest)
+{
+       emit(buf, 0x65); /* GS segment override prefix */
+       __emit_reg_memdisp(buf, 0x89, mach_reg(&src->reg), dest->imm);
+}
+
+static void emit_mov_reg_thread_local_membase(struct buffer *buf,
+                                             struct operand *src,
+                                             struct operand *dest)
+{
+       emit(buf, 0x65); /* GS segment override prefix */
+       emit_mov_reg_membase(buf, src, dest);
+}
+
+static void emit_mov_imm_thread_local_membase(struct buffer *buf,
+                                             struct operand *src,
+                                             struct operand *dest)
+{
+       emit(buf, 0x65); /* GS segment override prefix */
+       emit_mov_imm_membase(buf, src, dest);
+}
+
 static void emit_mov_memdisp_reg(struct buffer *buf,
                                 struct operand *src,
                                 struct operand *dest)
@@ -1314,6 +1343,7 @@ struct emitter emitters[] = {
        DECL_EMITTER(INSN_MOV_XMM_MEMBASE, emit_mov_xmm_membase, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_IMM_MEMBASE, emit_mov_imm_membase, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_IMM_REG, emit_mov_imm_reg, TWO_OPERANDS),
+       DECL_EMITTER(INSN_MOV_IMM_THREAD_LOCAL_MEMBASE, 
emit_mov_imm_thread_local_membase, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_MEMLOCAL_REG, emit_mov_memlocal_reg, 
TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_MEMLOCAL_FREG, emit_mov_memlocal_freg, 
TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_MEMBASE_REG, emit_mov_membase_reg, TWO_OPERANDS),
@@ -1324,6 +1354,8 @@ struct emitter emitters[] = {
        DECL_EMITTER(INSN_MOV_REG_MEMBASE, emit_mov_reg_membase, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_REG_MEMINDEX, emit_mov_reg_memindex, 
TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_REG_MEMLOCAL, emit_mov_reg_memlocal, 
TWO_OPERANDS),
+       DECL_EMITTER(INSN_MOV_REG_THREAD_LOCAL_MEMBASE, 
emit_mov_reg_thread_local_membase, TWO_OPERANDS),
+       DECL_EMITTER(INSN_MOV_REG_THREAD_LOCAL_MEMDISP, 
emit_mov_reg_thread_local_memdisp, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_FREG_MEMLOCAL, emit_mov_freg_memlocal, 
TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_REG_REG, emit_mov_reg_reg, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOVSX_8_REG_REG, emit_movsx_8_reg_reg, TWO_OPERANDS),
diff --git a/arch/x86/include/arch/instruction.h 
b/arch/x86/include/arch/instruction.h
index c8e3bb8..a5bd8da 100644
--- a/arch/x86/include/arch/instruction.h
+++ b/arch/x86/include/arch/instruction.h
@@ -87,11 +87,14 @@ enum insn_type {
        INSN_JNE_BRANCH,
        INSN_MOV_IMM_MEMBASE,
        INSN_MOV_IMM_REG,
+       INSN_MOV_IMM_THREAD_LOCAL_MEMBASE,
        INSN_MOV_MEMLOCAL_REG,
        INSN_MOV_MEMLOCAL_FREG,
        INSN_MOV_MEMBASE_REG,
        INSN_MOV_MEMDISP_REG,
        INSN_MOV_REG_MEMDISP,
+       INSN_MOV_REG_THREAD_LOCAL_MEMBASE,
+       INSN_MOV_REG_THREAD_LOCAL_MEMDISP,
        INSN_MOV_THREAD_LOCAL_MEMDISP_REG,
        INSN_MOV_MEMINDEX_REG,
        INSN_MOV_REG_MEMBASE,
diff --git a/arch/x86/lir-printer.c b/arch/x86/lir-printer.c
index c27c4f4..208fd28 100644
--- a/arch/x86/lir-printer.c
+++ b/arch/x86/lir-printer.c
@@ -133,6 +133,30 @@ static int print_tlmemdisp_reg(struct string *str, struct 
insn *insn)
        return print_reg(str, &insn->dest);
 }
 
+static int print_reg_tlmemdisp(struct string *str, struct insn *insn)
+{
+       print_reg(str, &insn->src);
+       str_append(str, ", gs:(");
+       print_imm(str, &insn->dest);
+       return str_append(str, ")");
+}
+
+static int print_imm_tlmembase(struct string *str, struct insn *insn)
+{
+       print_imm(str, &insn->src);
+       str_append(str, ", gs:(");
+       print_membase(str, &insn->dest);
+       return str_append(str, ")");
+}
+
+static int print_reg_tlmembase(struct string *str, struct insn *insn)
+{
+       print_reg(str, &insn->src);
+       str_append(str, ", gs:(");
+       print_membase(str, &insn->dest);
+       return str_append(str, ")");
+}
+
 static int print_reg_membase(struct string *str, struct insn *insn)
 {
        print_reg(str, &insn->src);
@@ -425,6 +449,24 @@ static int print_mov_tlmemdisp_reg(struct string *str, 
struct insn *insn)
        return print_tlmemdisp_reg(str, insn);
 }
 
+static int print_mov_reg_tlmemdisp(struct string *str, struct insn *insn)
+{
+       print_func_name(str);
+       return print_reg_tlmemdisp(str, insn);
+}
+
+static int print_mov_imm_tlmembase(struct string *str, struct insn *insn)
+{
+       print_func_name(str);
+       return print_imm_tlmembase(str, insn);
+}
+
+static int print_mov_reg_tlmembase(struct string *str, struct insn *insn)
+{
+       print_func_name(str);
+       return print_reg_tlmembase(str, insn);
+}
+
 static int print_mov_memindex_reg(struct string *str, struct insn *insn)
 {
        print_func_name(str);
@@ -668,6 +710,7 @@ static print_insn_fn insn_printers[] = {
        [INSN_JNE_BRANCH] = print_jne_branch,
        [INSN_MOV_IMM_MEMBASE] = print_mov_imm_membase,
        [INSN_MOV_IMM_REG] = print_mov_imm_reg,
+       [INSN_MOV_IMM_THREAD_LOCAL_MEMBASE] = print_mov_imm_tlmembase,
        [INSN_MOV_MEMLOCAL_REG] = print_mov_memlocal_reg,
        [INSN_MOV_MEMLOCAL_FREG] = print_mov_memlocal_freg,
        [INSN_MOV_MEMBASE_REG] = print_mov_membase_reg,
@@ -678,6 +721,8 @@ static print_insn_fn insn_printers[] = {
        [INSN_MOV_REG_MEMBASE] = print_mov_reg_membase,
        [INSN_MOV_REG_MEMINDEX] = print_mov_reg_memindex,
        [INSN_MOV_REG_MEMLOCAL] = print_mov_reg_memlocal,
+       [INSN_MOV_REG_THREAD_LOCAL_MEMBASE] = print_mov_reg_tlmembase,
+       [INSN_MOV_REG_THREAD_LOCAL_MEMDISP] = print_mov_reg_tlmemdisp,
        [INSN_MOV_FREG_MEMLOCAL] = print_mov_freg_memlocal,
        [INSN_MOV_REG_REG] = print_mov_reg_reg,
        [INSN_MOVSX_8_REG_REG] = print_movsx_8_reg_reg,
diff --git a/arch/x86/use-def.c b/arch/x86/use-def.c
index 1c7790c..3a140d0 100644
--- a/arch/x86/use-def.c
+++ b/arch/x86/use-def.c
@@ -74,6 +74,7 @@ static struct insn_info insn_infos[] = {
        DECLARE_INFO(INSN_JNE_BRANCH, USE_NONE | DEF_NONE),
        DECLARE_INFO(INSN_MOV_IMM_MEMBASE, USE_DST),
        DECLARE_INFO(INSN_MOV_IMM_REG, DEF_DST),
+       DECLARE_INFO(INSN_MOV_IMM_THREAD_LOCAL_MEMBASE, USE_NONE | DEF_NONE),
        DECLARE_INFO(INSN_MOV_MEMLOCAL_REG, USE_FP | DEF_DST),
        DECLARE_INFO(INSN_MOV_MEMLOCAL_FREG, USE_FP | DEF_DST),
        DECLARE_INFO(INSN_MOV_MEMBASE_REG, USE_SRC | DEF_DST),
@@ -83,6 +84,8 @@ static struct insn_info insn_infos[] = {
        DECLARE_INFO(INSN_MOV_MEMINDEX_REG, USE_SRC | USE_IDX_SRC | DEF_DST),
        DECLARE_INFO(INSN_MOV_REG_MEMINDEX, USE_SRC | USE_DST | USE_IDX_DST | 
DEF_NONE),
        DECLARE_INFO(INSN_MOV_REG_MEMLOCAL, USE_SRC),
+       DECLARE_INFO(INSN_MOV_REG_THREAD_LOCAL_MEMBASE, USE_SRC | DEF_NONE),
+       DECLARE_INFO(INSN_MOV_REG_THREAD_LOCAL_MEMDISP, USE_SRC | DEF_NONE),
        DECLARE_INFO(INSN_MOV_FREG_MEMLOCAL, USE_SRC),
        DECLARE_INFO(INSN_MOV_REG_REG, USE_SRC | DEF_DST),
        DECLARE_INFO(INSN_MOVSX_8_REG_REG, USE_SRC | DEF_DST),
-- 
1.6.0.6


------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to