aboutsummaryrefslogtreecommitdiff
path: root/x86_64-gen.c
diff options
context:
space:
mode:
authorJames Lyon <jamesly0n@hotmail.com>2013-04-25 22:30:53 +0100
committerJames Lyon <jamesly0n@hotmail.com>2013-04-25 22:30:53 +0100
commit1caee8ab3b6c3cf3ceb06d1ec4a5e09e2d90c543 (patch)
tree8030bbd2960b6951864d1bc21d634d6a95379196 /x86_64-gen.c
parente7a7efed11792e0dbc14a66b02fa7b25886f69d8 (diff)
downloadtinycc-1caee8ab3b6c3cf3ceb06d1ec4a5e09e2d90c543.tar.gz
tinycc-1caee8ab3b6c3cf3ceb06d1ec4a5e09e2d90c543.tar.bz2
Sorted out CMake on x86-64 and fixed silly XMM# bug introduced when working on Win64 stdargs.
I removed the XMM6/7 registers from the register list because they are not used on Win64 however they are necessary for parameter passing on x86-64. I have now restored them but not marked them with RC_FLOAT so they will not be used except for parameter passing.
Diffstat (limited to 'x86_64-gen.c')
-rw-r--r--x86_64-gen.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/x86_64-gen.c b/x86_64-gen.c
index 1cf3bbc..3e892e3 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -23,7 +23,7 @@
#ifdef TARGET_DEFS_ONLY
/* number of available registers */
-#define NB_REGS 22
+#define NB_REGS 24
#define NB_ASM_REGS 8
/* a register can belong to several classes. The classes must be
@@ -45,6 +45,8 @@
#define RC_XMM3 0x8000
#define RC_XMM4 0x10000
#define RC_XMM5 0x20000
+#define RC_XMM6 0x40000
+#define RC_XMM7 0x80000
#define RC_IRET RC_RAX /* function return: integer register */
#define RC_LRET RC_RDX /* function return: second integer register */
#define RC_FRET RC_XMM0 /* function return: float register */
@@ -140,7 +142,12 @@ ST_DATA const int reg_classes[NB_REGS] = {
/* xmm2 */ RC_FLOAT | RC_XMM2,
/* xmm3 */ RC_FLOAT | RC_XMM3,
/* xmm4 */ RC_FLOAT | RC_XMM4,
- /* xmm5 */ RC_FLOAT | RC_XMM5 /* only up to xmm5: xmm6-15 must be callee saved on Win64 */
+ /* xmm5 */ RC_FLOAT | RC_XMM5,
+ /* xmm6 an xmm7 are included so gv() can be used on them,
+ but they are not tagged with RC_FLOAT because they are
+ callee saved on Windows */
+ RC_XMM6,
+ RC_XMM7
};
static unsigned long func_sub_sp_offset;
@@ -499,7 +506,7 @@ void load(int r, SValue *sv)
o(0xc0 + REG_VALUE(v) + REG_VALUE(r)*8);
}
} else if (r == TREG_ST0) {
- assert((v == TREG_XMM0) || (v == TREG_XMM1));
+ assert((v >= TREG_XMM0) || (v <= TREG_XMM7));
/* gen_cvt_ftof(VT_LDOUBLE); */
/* movsd %xmmN,-0x10(%rsp) */
o(0x110ff2);
@@ -1173,7 +1180,7 @@ void gfunc_call(int nb_args)
--sse_reg;
r = gv(RC_FLOAT);
o(0x50); /* push $rax */
- /* movq %xmm0, (%rsp) */
+ /* movq %xmmN, (%rsp) */
o(0xd60f66);
o(0x04 + REG_VALUE(r)*8);
o(0x24);