From fd037f35e9a04fcb457e2d6666fbf377f24d446d Mon Sep 17 00:00:00 2001 From: Frits van Bommel Date: Mon, 1 Jun 2009 23:17:47 +0200 Subject: [PATCH 1/2] Fix a type mismatch in ModuleInfo generation. --- gen/tollvm.cpp | 8 ++++++++ gen/tollvm.h | 1 + gen/toobj.cpp | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 687c86b0..23b04f3d 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -403,6 +403,14 @@ LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm:: ////////////////////////////////////////////////////////////////////////////////////////// +LLConstant* DtoGEPi(LLConstant* ptr, unsigned i0, unsigned i1) +{ + LLValue* v[2] = { DtoConstUint(i0), DtoConstUint(i1) }; + return llvm::ConstantExpr::getGetElementPtr(ptr, v, 2); +} + +////////////////////////////////////////////////////////////////////////////////////////// + void DtoMemSetZero(LLValue* dst, LLValue* nbytes) { dst = DtoBitCast(dst,getVoidPtrType()); diff --git a/gen/tollvm.h b/gen/tollvm.h index 6f28813d..f77889b0 100644 --- a/gen/tollvm.h +++ b/gen/tollvm.h @@ -48,6 +48,7 @@ LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var=NULL, ll LLValue* DtoGEPi1(LLValue* ptr, unsigned i0, const char* var=NULL, llvm::BasicBlock* bb=NULL); LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var=NULL, llvm::BasicBlock* bb=NULL); +LLConstant* DtoGEPi(LLConstant* ptr, unsigned i0, unsigned i1); // to constant helpers LLConstantInt* DtoConstSize_t(uint64_t); diff --git a/gen/toobj.cpp b/gen/toobj.cpp index 93f31411..42d5a19c 100644 --- a/gen/toobj.cpp +++ b/gen/toobj.cpp @@ -715,11 +715,11 @@ void Module::genmoduleinfo() m_name.append("9__classesZ"); assert(gIR->module->getGlobalVariable(m_name) == NULL); llvm::GlobalVariable* m_gvar = new llvm::GlobalVariable(classArrTy, true, llvm::GlobalValue::InternalLinkage, c, m_name, gIR->module); - c = DtoBitCast(m_gvar, getPtrToType(classinfoTy)); + c = DtoGEPi(m_gvar, 0, 0); c = DtoConstSlice(DtoConstSize_t(classInits.size()), c); } else - c = DtoConstSlice( DtoConstSize_t(0), getNullValue(getPtrToType(classinfoTy)) ); + c = DtoConstSlice( DtoConstSize_t(0), getNullValue(getPtrToType(getPtrToType(classinfoTy))) ); b.push(c); // flags (4 means MIstandalone) From ba72e39d24c201d4e0686f2c688cdd2dd929dfc9 Mon Sep 17 00:00:00 2001 From: Frits van Bommel Date: Mon, 1 Jun 2009 23:42:42 +0200 Subject: [PATCH 2/2] Add `syscall` to the x86-64 asm parser, and both `syscall` and `sysret` to the x86 one. Fixes #316. --- gen/asm-x86-32.h | 2 ++ gen/asm-x86-64.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gen/asm-x86-32.h b/gen/asm-x86-32.h index 0b9ab5c2..746669a7 100644 --- a/gen/asm-x86-32.h +++ b/gen/asm-x86-32.h @@ -1100,8 +1100,10 @@ namespace AsmParserx8632 { "subps", Op_DstSrcSSE }, { "subsd", Op_DstSrcSSE }, { "subss", Op_DstSrcSSE }, + { "syscall", Op_0 }, { "sysenter",Op_0 }, { "sysexit", Op_0 }, + { "sysret", Op_0 }, { "test", Op_SrcSrcF }, { "ucomisd", Op_SrcSrcSSEF }, { "ucomiss", Op_SrcSrcSSEF }, diff --git a/gen/asm-x86-64.h b/gen/asm-x86-64.h index b182f7a7..bf04c26a 100644 --- a/gen/asm-x86-64.h +++ b/gen/asm-x86-64.h @@ -730,7 +730,6 @@ namespace AsmParserx8664 { "invlpga", Op_SrcMemNT }, { "rdtscp", Op_0_DXAX }, { "stgi", Op_Flags }, - { "sysret", Op_0 }, */ { "cmpxch16b", Op_cmpxchg8b }, @@ -1221,6 +1220,7 @@ namespace AsmParserx8664 { "subsd", Op_DstSrcSSE }, { "subss", Op_DstSrcSSE }, { "swapgs", Op_DstSrcSSE }, + { "syscall", Op_0 }, { "sysenter",Op_0 }, { "sysexit", Op_0 }, { "sysret", Op_0 },