mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Fixed issues with global var addresses in const arrays
This commit is contained in:
parent
52af512b4f
commit
b30a72719c
13 changed files with 376 additions and 36 deletions
|
@ -709,7 +709,7 @@ void BfIRCodeGen::Read(llvm::Value*& llvmValue, BfIRCodeGenEntry** codeGenEntry)
|
|||
CMD_PARAM(int, streamId);
|
||||
if (streamId == -1)
|
||||
{
|
||||
int streamId = mCmdCount++;
|
||||
int streamId = mCmdCount++;
|
||||
|
||||
CMD_PARAM(llvm::Type*, varType);
|
||||
CMD_PARAM(bool, isConstant);
|
||||
|
@ -718,13 +718,17 @@ void BfIRCodeGen::Read(llvm::Value*& llvmValue, BfIRCodeGenEntry** codeGenEntry)
|
|||
CMD_PARAM(String, name);
|
||||
CMD_PARAM(bool, isTLS);
|
||||
|
||||
auto globalVariable = new llvm::GlobalVariable(
|
||||
*mLLVMModule,
|
||||
varType,
|
||||
isConstant,
|
||||
LLVMMapLinkageType(linkageType),
|
||||
initializer,
|
||||
name.c_str(), NULL, isTLS ? llvm::GlobalValue::GeneralDynamicTLSModel : llvm::GlobalValue::NotThreadLocal);
|
||||
llvm::GlobalVariable* globalVariable = mLLVMModule->getGlobalVariable(name.c_str(), true);
|
||||
if (globalVariable == NULL)
|
||||
{
|
||||
globalVariable = new llvm::GlobalVariable(
|
||||
*mLLVMModule,
|
||||
varType,
|
||||
isConstant,
|
||||
LLVMMapLinkageType(linkageType),
|
||||
initializer,
|
||||
name.c_str(), NULL, isTLS ? llvm::GlobalValue::GeneralDynamicTLSModel : llvm::GlobalValue::NotThreadLocal);
|
||||
}
|
||||
llvmValue = globalVariable;
|
||||
|
||||
SetResult(streamId, globalVariable);
|
||||
|
@ -791,6 +795,15 @@ void BfIRCodeGen::Read(llvm::Value*& llvmValue, BfIRCodeGenEntry** codeGenEntry)
|
|||
llvmValue = llvm::ConstantExpr::getInBoundsGetElementPtr(NULL, target, gepArgs);
|
||||
return;
|
||||
}
|
||||
else if (constType == BfConstType_ExtractValue)
|
||||
{
|
||||
CMD_PARAM(llvm::Constant*, target);
|
||||
CMD_PARAM(int, idx0);
|
||||
unsigned int gepArgs[] = {
|
||||
(unsigned int)idx0 };
|
||||
llvmValue = llvm::ConstantExpr::getExtractValue(target, gepArgs);
|
||||
return;
|
||||
}
|
||||
else if (constType == BfConstType_PtrToInt)
|
||||
{
|
||||
CMD_PARAM(llvm::Constant*, target);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue