@@ -53,11 +53,6 @@ class BackendX86_64 : CompilerBackend {
5353
5454 this () {
5555 output = new Output();
56- output.macros[" QWORD" ] = useGas? " qword ptr" : " qword" ;
57- output.macros[" DWORD" ] = useGas? " dword ptr" : " dword" ;
58- output.macros[" WORD" ] = useGas? " word ptr" : " word" ;
59- output.macros[" BYTE" ] = useGas? " byte ptr" : " byte" ;
60-
6156 addrSize = 8 ;
6257
6358 version (linux ) {
@@ -272,7 +267,7 @@ class BackendX86_64 : CompilerBackend {
272267 foreach (global ; globals) {
273268 if (global.type.hasInit && ! global.type.ptr) {
274269 output ~= format(
275- " lea rax, qword [ __global_%s] \n " , global.name.Sanitise()
270+ " lea rax, __global_%s\n " , global.name.Sanitise()
276271 );
277272 output ~= " mov [r15], rax\n " ;
278273 output ~= " add r15, 8\n " ;
@@ -301,6 +296,11 @@ class BackendX86_64 : CompilerBackend {
301296 }
302297
303298 override void Init () {
299+ output.macros[" QWORD" ] = useGas? " qword ptr" : " qword" ;
300+ output.macros[" DWORD" ] = useGas? " dword ptr" : " dword" ;
301+ output.macros[" WORD" ] = useGas? " word ptr" : " word" ;
302+ output.macros[" BYTE" ] = useGas? " byte ptr" : " byte" ;
303+
304304 string [] oses = [" linux" , " bare-metal" , " osx" , " freebsd" ];
305305 if (! oses.canFind(os)) {
306306 ErrorNoInfo(" Backend doesn't support operating system '%s'" , os);
@@ -376,7 +376,7 @@ class BackendX86_64 : CompilerBackend {
376376 // call destructors
377377 foreach (global ; globals) {
378378 if (global.type.hasDeinit && ! global.type.ptr) {
379- output ~= format(" lea rax, qword [ __global_%s] \n " , Sanitise(global.name));
379+ output ~= format(" lea rax, __global_%s\n " , Sanitise(global.name));
380380 output ~= " mov [r15], rax\n " ;
381381 output ~= " add r15, 8\n " ;
382382 output ~= format(" call __type_deinit_%s\n " , Sanitise(global.type.name));
@@ -624,7 +624,7 @@ class BackendX86_64 : CompilerBackend {
624624 // push parameters
625625 foreach_reverse (i ; 6 .. word.params.length) {
626626 output ~= format(
627- " push qword [r15 - %d]\n " , (word.params.length - i) * 8
627+ " push $(QWORD) [r15 - %d]\n " , (word.params.length - i) * 8
628628 );
629629 }
630630 }
@@ -673,13 +673,15 @@ class BackendX86_64 : CompilerBackend {
673673
674674 if (crash) {
675675 output ~= format(" lea rax, __global_%s\n " , Sanitise(" _cal_exception" ));
676- output ~= " cmp qword [rax], 0\n " ;
676+ output ~= " cmp $(QWORD) [rax], 0\n " ;
677677 output ~= format(" jne __func__%s\n " , Sanitise(" __x86_64_exception" ));
678678 }
679679 else {
680680 string temp = TempLabel();
681681
682- output ~= format(" cmp qword [__global_%s], 0\n " , Sanitise(" _cal_exception" ));
682+ output ~= format(
683+ " cmp $(QWORD) [__global_%s], 0\n " , Sanitise(" _cal_exception" )
684+ );
683685 output ~= format(" je %s\n " , temp);
684686 output ~= " mov r15, r14\n " ;
685687 CompileReturn(node);
@@ -1269,7 +1271,7 @@ class BackendX86_64 : CompilerBackend {
12691271 auto var = GetGlobal(node.func);
12701272
12711273 output ~= format(
1272- " lea rax, qword [ __global_%s] \n " , node.func.Sanitise()
1274+ " lea rax, __global_%s\n " , node.func.Sanitise()
12731275 );
12741276 output ~= " mov [r15], rax\n " ;
12751277 output ~= " add r15, 8\n " ;
@@ -1301,7 +1303,7 @@ class BackendX86_64 : CompilerBackend {
13011303 }
13021304 else {
13031305 output ~= format(
1304- " lea rax, qword [__global_%s + %d]\n " , name.Sanitise(), offset
1306+ " lea rax, [__global_%s + %d]\n " , name.Sanitise(), offset
13051307 );
13061308 }
13071309
@@ -1561,7 +1563,7 @@ class BackendX86_64 : CompilerBackend {
15611563 ++ blockCounter;
15621564
15631565 output ~= format(" lea rax, __global_%s\n " , Sanitise(" _cal_exception" ));
1564- output ~= " cmp qword [rax], 0\n " ;
1566+ output ~= " cmp $(QWORD) [rax], 0\n " ;
15651567 output ~= format(" je __catch_%d_end\n " , blockCounter);
15661568
15671569 // function errored, assume that all it did was consume parameters
0 commit comments