summaryrefslogtreecommitdiff
path: root/src/qcommon/vm_x86.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/qcommon/vm_x86.c')
-rw-r--r--src/qcommon/vm_x86.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/qcommon/vm_x86.c b/src/qcommon/vm_x86.c
index 72225473..9e30e32f 100644
--- a/src/qcommon/vm_x86.c
+++ b/src/qcommon/vm_x86.c
@@ -150,7 +150,7 @@ static void EmitPtr(void *ptr)
intptr_t v = (intptr_t) ptr;
Emit4(v);
-#ifdef idx64
+#if idx64
Emit1((v >> 32) & 0xFF);
Emit1((v >> 40) & 0xFF);
Emit1((v >> 48) & 0xFF);
@@ -193,7 +193,7 @@ static void EmitString( const char *string ) {
}
static void EmitRexString(byte rex, const char *string)
{
-#ifdef idx64
+#if idx64
if(rex)
Emit1(rex);
#endif
@@ -416,7 +416,7 @@ Uses asm to retrieve arguments from registers to work around different calling c
=================
*/
-#if defined(_MSC_VER) && defined(idx64)
+#if defined(_MSC_VER) && idx64
extern void qsyscall64(void);
extern uint8_t qvmcall64(int *programStack, int *opStack, intptr_t *instructionPointers, byte *dataBase);
@@ -458,7 +458,7 @@ static void DoSyscall(void)
if(syscallNum < 0)
{
int *data;
-#ifdef idx64
+#if idx64
int index;
intptr_t args[11];
#endif
@@ -470,7 +470,7 @@ static void DoSyscall(void)
// modify VM stack pointer for recursive VM entry
savedVM->programStack = programStack - 4;
-#ifdef idx64
+#if idx64
args[0] = ~syscallNum;
for(index = 1; index < ARRAY_LEN(args); index++)
args[index] = data[index];
@@ -526,7 +526,7 @@ Call to DoSyscall()
int EmitCallDoSyscall(vm_t *vm)
{
// use edx register to store DoSyscall address
-#if defined(_MSC_VER) && defined(idx64)
+#if defined(_MSC_VER) && idx64
EmitRexString(0x48, "BA"); // mov edx, qsyscall64
EmitPtr(qsyscall64);
#else
@@ -539,7 +539,7 @@ int EmitCallDoSyscall(vm_t *vm)
EmitString("51"); // push ebx
EmitString("56"); // push esi
EmitString("57"); // push edi
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "50"); // push r8
EmitRexString(0x41, "51"); // push r9
#endif
@@ -557,7 +557,7 @@ int EmitCallDoSyscall(vm_t *vm)
EmitRexString(0x48, "89 EC"); // mov esp, ebp
EmitString("5D"); // pop ebp
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "59"); // pop r9
EmitRexString(0x41, "58"); // pop r8
#endif
@@ -614,7 +614,7 @@ int EmitCallProcedure(vm_t *vm, int sysCallOfs)
EmitString("73"); // jae badAddr
jmpBadAddr = compiledOfs++;
-#ifdef idx64
+#if idx64
EmitRexString(0x49, "FF 14 C0"); // call qword ptr [r8 + eax * 8]
#else
EmitString("FF 14 85"); // call dword ptr [vm->instructionPointers + eax * 4]
@@ -770,7 +770,7 @@ qboolean ConstOptimize(vm_t *vm, int callProcOfsSyscall)
case OP_LOAD4:
EmitPushStack(vm);
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "8B 81"); // mov eax, dword ptr [r9 + 0x12345678]
Emit4(Constant4() & vm->dataMask);
#else
@@ -786,7 +786,7 @@ qboolean ConstOptimize(vm_t *vm, int callProcOfsSyscall)
case OP_LOAD2:
EmitPushStack(vm);
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "0F B7 81"); // movzx eax, word ptr [r9 + 0x12345678]
Emit4(Constant4() & vm->dataMask);
#else
@@ -802,7 +802,7 @@ qboolean ConstOptimize(vm_t *vm, int callProcOfsSyscall)
case OP_LOAD1:
EmitPushStack(vm);
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "0F B6 81"); // movzx eax, byte ptr [r9 + 0x12345678]
Emit4(Constant4() & vm->dataMask);
#else
@@ -818,7 +818,7 @@ qboolean ConstOptimize(vm_t *vm, int callProcOfsSyscall)
case OP_STORE4:
EmitMovEAXStack(vm, (vm->dataMask & ~3));
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "C7 04 01"); // mov dword ptr [r9 + eax], 0x12345678
Emit4(Constant4());
#else
@@ -833,7 +833,7 @@ qboolean ConstOptimize(vm_t *vm, int callProcOfsSyscall)
case OP_STORE2:
EmitMovEAXStack(vm, (vm->dataMask & ~1));
-#ifdef idx64
+#if idx64
Emit1(0x66); // mov word ptr [r9 + eax], 0x1234
EmitRexString(0x41, "C7 04 01");
Emit2(Constant4());
@@ -850,7 +850,7 @@ qboolean ConstOptimize(vm_t *vm, int callProcOfsSyscall)
case OP_STORE1:
EmitMovEAXStack(vm, vm->dataMask);
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "C6 04 01"); // mov byte [r9 + eax], 0x12
Emit1(Constant4());
#else
@@ -1209,7 +1209,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
EmitString("81 C2"); // add edx, 0x12345678
Emit4((Constant1() & 0xFF));
MASK_REG("E2", vm->dataMask); // and edx, 0x12345678
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "89 04 11"); // mov dword ptr [r9 + edx], eax
#else
EmitString("89 82"); // mov dword ptr [edx + 0x12345678], eax
@@ -1247,7 +1247,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
EmitMovEDXStack(vm, vm->dataMask);
if(v == 1 && oc0 == oc1 && pop0 == OP_LOCAL && pop1 == OP_LOCAL)
{
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "FF 04 11"); // inc dword ptr [r9 + edx]
#else
EmitString("FF 82"); // inc dword ptr [edx + 0x12345678]
@@ -1256,7 +1256,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
}
else
{
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "8B 04 11"); // mov eax, dword ptr [r9 + edx]
#else
EmitString("8B 82"); // mov eax, dword ptr [edx + 0x12345678]
@@ -1267,7 +1267,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
if (oc0 == oc1 && pop0 == OP_LOCAL && pop1 == OP_LOCAL)
{
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "89 04 11"); // mov dword ptr [r9 + edx], eax
#else
EmitString("89 82"); // mov dword ptr [edx + 0x12345678], eax
@@ -1279,7 +1279,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
EmitCommand(LAST_COMMAND_SUB_BL_1); // sub bl, 1
EmitString("8B 14 9F"); // mov edx, dword ptr [edi + ebx * 4]
MASK_REG("E2", vm->dataMask); // and edx, 0x12345678
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "89 04 11"); // mov dword ptr [r9 + edx], eax
#else
EmitString("89 82"); // mov dword ptr [edx + 0x12345678], eax
@@ -1309,7 +1309,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
EmitMovEDXStack(vm, vm->dataMask);
if(v == 1 && oc0 == oc1 && pop0 == OP_LOCAL && pop1 == OP_LOCAL)
{
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "FF 0C 11"); // dec dword ptr [r9 + edx]
#else
EmitString("FF 8A"); // dec dword ptr [edx + 0x12345678]
@@ -1318,7 +1318,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
}
else
{
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "8B 04 11"); // mov eax, dword ptr [r9 + edx]
#else
EmitString("8B 82"); // mov eax, dword ptr [edx + 0x12345678]
@@ -1329,7 +1329,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
if(oc0 == oc1 && pop0 == OP_LOCAL && pop1 == OP_LOCAL)
{
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "89 04 11"); // mov dword ptr [r9 + edx], eax
#else
EmitString("89 82"); // mov dword ptr [edx + 0x12345678], eax
@@ -1341,7 +1341,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
EmitCommand(LAST_COMMAND_SUB_BL_1); // sub bl, 1
EmitString("8B 14 9F"); // mov edx, dword ptr [edi + ebx * 4]
MASK_REG("E2", vm->dataMask); // and edx, 0x12345678
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "89 04 11"); // mov dword ptr [r9 + edx], eax
#else
EmitString("89 82"); // mov dword ptr [edx + 0x12345678], eax
@@ -1361,7 +1361,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
compiledOfs -= 3;
vm->instructionPointers[instruction - 1] = compiledOfs;
MASK_REG("E0", vm->dataMask); // and eax, 0x12345678
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "8B 04 01"); // mov eax, dword ptr [r9 + eax]
#else
EmitString("8B 80"); // mov eax, dword ptr [eax + 0x1234567]
@@ -1372,7 +1372,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
}
EmitMovEAXStack(vm, vm->dataMask);
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "8B 04 01"); // mov eax, dword ptr [r9 + eax]
#else
EmitString("8B 80"); // mov eax, dword ptr [eax + 0x12345678]
@@ -1382,7 +1382,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
break;
case OP_LOAD2:
EmitMovEAXStack(vm, vm->dataMask);
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "0F B7 04 01"); // movzx eax, word ptr [r9 + eax]
#else
EmitString("0F B7 80"); // movzx eax, word ptr [eax + 0x12345678]
@@ -1392,7 +1392,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
break;
case OP_LOAD1:
EmitMovEAXStack(vm, vm->dataMask);
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "0F B6 04 01"); // movzx eax, byte ptr [r9 + eax]
#else
EmitString("0F B6 80"); // movzx eax, byte ptr [eax + 0x12345678]
@@ -1404,7 +1404,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
EmitMovEAXStack(vm, 0);
EmitString("8B 54 9F FC"); // mov edx, dword ptr -4[edi + ebx * 4]
MASK_REG("E2", vm->dataMask & ~3); // and edx, 0x12345678
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "89 04 11"); // mov dword ptr [r9 + edx], eax
#else
EmitString("89 82"); // mov dword ptr [edx + 0x12345678], eax
@@ -1416,7 +1416,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
EmitMovEAXStack(vm, 0);
EmitString("8B 54 9F FC"); // mov edx, dword ptr -4[edi + ebx * 4]
MASK_REG("E2", vm->dataMask & ~1); // and edx, 0x12345678
-#ifdef idx64
+#if idx64
Emit1(0x66); // mov word ptr [r9 + edx], eax
EmitRexString(0x41, "89 04 11");
#else
@@ -1429,7 +1429,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
EmitMovEAXStack(vm, 0);
EmitString("8B 54 9F FC"); // mov edx, dword ptr -4[edi + ebx * 4]
MASK_REG("E2", vm->dataMask); // and edx, 0x12345678
-#ifdef idx64
+#if idx64
EmitRexString(0x41, "88 04 11"); // mov byte ptr [r9 + edx], eax
#else
EmitString("88 82"); // mov byte ptr [edx + 0x12345678], eax
@@ -1652,7 +1652,7 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
EmitString("8B 44 9F 04"); // mov eax, dword ptr 4[edi + ebx * 4]
EmitString("81 F8"); // cmp eax, vm->instructionCount
Emit4(vm->instructionCount);
-#ifdef idx64
+#if idx64
EmitString("73 04"); // jae +4
EmitRexString(0x49, "FF 24 C0"); // jmp qword ptr [r8 + eax * 8]
#else
@@ -1780,7 +1780,7 @@ int VM_CallCompiled(vm_t *vm, int *args)
opStackOfs = 0;
#ifdef _MSC_VER
- #ifdef idx64
+ #if idx64
opStackOfs = qvmcall64(&programStack, opStack, vm->instructionPointers, vm->dataBase);
#else
__asm
@@ -1800,7 +1800,7 @@ int VM_CallCompiled(vm_t *vm, int *args)
popad
}
#endif
-#elif defined(idx64)
+#elif idx64
__asm__ volatile(
"movq %5, %%rax\r\n"
"movq %3, %%r8\r\n"