Explorar o código

Const GEP32_1 support

Brian Fiete %!s(int64=3) %!d(string=hai) anos
pai
achega
8155d7286a
Modificáronse 2 ficheiros con 18 adicións e 0 borrados
  1. 8 0
      IDEHelper/Compiler/BfIRBuilder.cpp
  2. 10 0
      IDEHelper/Compiler/BfIRCodeGen.cpp

+ 8 - 0
IDEHelper/Compiler/BfIRBuilder.cpp

@@ -2367,6 +2367,14 @@ void BfIRBuilder::Write(const BfIRValue& irValue)
 				Write(bitcast->mToType);
 			}
 			break;
+		case (int)BfConstType_GEP32_1:
+			{
+				auto gepConst = (BfConstantGEP32_1*)constant;
+				BfIRValue targetConst(BfIRValueFlags_Const, gepConst->mTarget);
+				Write(targetConst);
+				Write(gepConst->mIdx0);
+			}
+			break;
 		case (int)BfConstType_GEP32_2:
 			{
 				auto gepConst = (BfConstantGEP32_2*)constant;

+ 10 - 0
IDEHelper/Compiler/BfIRCodeGen.cpp

@@ -923,6 +923,16 @@ void BfIRCodeGen::Read(llvm::Value*& llvmValue, BfIRCodeGenEntry** codeGenEntry,
 				llvmValue = llvm::ConstantExpr::getBitCast(target, toType);
 			return;
 		}
+		else if (constType == BfConstType_GEP32_1)
+		{
+			CMD_PARAM(llvm::Constant*, target);
+			CMD_PARAM(int, idx0);			
+			llvm::Value* gepArgs[] = { 
+				llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), idx0)};
+
+			llvmValue = FixGEP(target, llvm::ConstantExpr::getInBoundsGetElementPtr(target->getType()->getPointerElementType(), target, gepArgs));
+			return;
+		}
 		else if (constType == BfConstType_GEP32_2)
 		{
 			CMD_PARAM(llvm::Constant*, target);