I tested your code under 64-bit Linux and it works for me, the output:
; Function Prototype:
;
; IDX| Type | Sz | Home |
; ---+----------+----+----------------+
; 0 | GP.Q | 8 | rdi |
; 1 | GP.Q | 8 | rsi |
;
; Variables:
;
; ID | Type | Sz | Home | Register Access | Memory Access |
; ---+----------+----+----------------+-------------------+-------------------+
; 0 | GP.Q | 8 | [None] | r=0 w=0 x=0 | r=0 w=0 x=0 |
; 1 | GP.Q | 8 | [None] | r=0 w=0 x=0 | r=0 w=0 x=0 |
; 2 | GP.Q | 8 | [None] | r=0 w=0 x=1 | r=0 w=0 x=0 |
;
; Modified registers (3):
; GP : rcx, rsi, rdi
; MM :
; XMM:
L.0:
; Prolog
; Body
xor rcx, rcx
L.1:
; Epilog
ret
*** COMPILER SUCCESS - Wrote 4 bytes, code: 4, trampolines: 0.
Could you post your full code please? Maybe there is something else wrong.
Best regards
Petr Kobalicek
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <AsmJit/Compiler.h>
#include <AsmJit/Logger.h>
#include <AsmJit/MemoryManager.h>
// This is type of function we will generate
typedef void (*MyFn)(long*, long*);
int main(int argc, char* argv[])
{
using namespace AsmJit;
// Create compiler.
Compiler c;
// Log compiler output.
FileLogger logger(stderr);
c.setLogger(&logger);
c.newFunction(CALL_CONV_DEFAULT, FunctionBuilder2<Void, long*, long*>());
c.getFunction()->setHint(FUNCTION_HINT_NAKED, true);
GPVar stack(c.argGP(0));
GPVar memory(c.argGP(1));
GPVar x1(c.newGP(VARIABLE_TYPE_GPQ));
c.xor_(x1, x1);
c.endFunction();
// Make the function.
MyFn fn = function_cast<MyFn>(c.make());
// Call it.
// printf("Result %llu\n", (unsigned long long)fn());
// Free the generated function if it's not needed anymore.
MemoryManager::getGlobal()->free((void*)fn);
return 0;
}
Best regards
Petr Kobalicek
could you send me the output of this?
#if defined(ASMJIT_X86)
printf("x86\n");
#endif
#if defined(ASMJIT_X64)
printf("x64\n");
#endif
printf("%d", (int)sizeof(void*))
Maybe it's only 64-bit detection issue. I'm guessing only.
Best regards
Petr Kobalicek
BTW: It seems that you are using release build, maybe switching to
debug will trigger some assertion.
Best regards
Petr Kobalicek
so I can add mac-os-x 64 bit as a supported platform on the home-page ;-)
Thanks!
Petr Kobalicek