From b264b461f7569663018f60c72d54437487ca2d84 Mon Sep 17 00:00:00 2001 From: surpassgoodchao Date: Tue, 12 Oct 2021 15:50:12 +0800 Subject: [PATCH] conflicts Signed-off-by: surpassgoodchao --- ecmascript/compiler/llvm_ir_builder.cpp | 38 +++---------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/ecmascript/compiler/llvm_ir_builder.cpp b/ecmascript/compiler/llvm_ir_builder.cpp index 36ea4d96f4..2db295dec2 100644 --- a/ecmascript/compiler/llvm_ir_builder.cpp +++ b/ecmascript/compiler/llvm_ir_builder.cpp @@ -14,10 +14,8 @@ */ #include "ecmascript/compiler/llvm_ir_builder.h" - #include #include - #include "ecmascript/compiler/circuit.h" #include "ecmascript/compiler/fast_stub.h" #include "ecmascript/compiler/gate.h" @@ -26,32 +24,16 @@ #include "ecmascript/js_thread.h" #include "llvm/IR/Instructions.h" #include "llvm/Support/Host.h" -#include "llvm_mcjit_engine.h" #include "securec.h" #include "utils/logger.h" namespace kungfu { std::unordered_map g_values = {}; -LLVMIRBuilder::LLVMIRBuilder(const std::vector> *schedule, const Circuit *circuit) - : schedule_(schedule), circuit_(circuit) -{ - module_ = LLVMModuleCreateWithName("simple_module"); - LLVMSetTarget(module_, "x86_64-unknown-linux-gnu"); - builder_ = LLVMCreateBuilder(); - context_ = LLVMGetGlobalContext(); - LLVMTypeRef paramTys[] = { - LLVMInt32Type(), - }; - function_ = LLVMAddFunction(module_, "foo", LLVMFunctionType(LLVMInt32Type(), paramTys, 1, 0)); - bbIdMapBb_.clear(); -} - LLVMIRBuilder::LLVMIRBuilder(const std::vector> *schedule, const Circuit *circuit, LLVMModuleRef module, LLVMValueRef function) : schedule_(schedule), circuit_(circuit), module_(module), function_(function) { - LLVMSetTarget(module_, "x86_64-unknown-linux-gnu"); builder_ = LLVMCreateBuilder(); context_ = LLVMGetGlobalContext(); bbIdMapBb_.clear(); @@ -62,7 +44,6 @@ LLVMIRBuilder::LLVMIRBuilder(const std::vector> *schedule : schedule_(schedule), circuit_(circuit), module_(module->GetModule()), function_(function), stubModule_(module) { - LLVMSetTarget(module_, "x86_64-unknown-linux-gnu"); builder_ = LLVMCreateBuilder(); context_ = LLVMGetGlobalContext(); bbIdMapBb_.clear(); @@ -666,8 +647,6 @@ void LLVMIRBuilder::HandleSExtInt(AddrShift gate) void LLVMIRBuilder::VisitInt32Constant(AddrShift gate, int32_t value) const { LLVMValueRef llvmValue = LLVMConstInt(LLVMInt32Type(), value, 0); - LLVMTFBuilderBasicBlockImpl *impl = currentBb_->GetImpl(); - impl->values_[gate] = llvmValue; g_values[gate] = llvmValue; char *str = LLVMPrintValueToString(llvmValue); LOG_ECMA(INFO) << "VisitInt32Constant set gate:" << gate << " value:" << value; @@ -677,8 +656,6 @@ void LLVMIRBuilder::VisitInt32Constant(AddrShift gate, int32_t value) const void LLVMIRBuilder::VisitInt64Constant(AddrShift gate, int64_t value) const { LLVMValueRef llvmValue = LLVMConstInt(LLVMInt64Type(), value, 0); - LLVMTFBuilderBasicBlockImpl *impl = currentBb_->GetImpl(); - impl->values_[gate] = llvmValue; g_values[gate] = llvmValue; char *str = LLVMPrintValueToString(llvmValue); LOG_ECMA(INFO) << "VisitInt64Constant set gate:" << gate << " value:" << value; @@ -688,8 +665,6 @@ void LLVMIRBuilder::VisitInt64Constant(AddrShift gate, int64_t value) const void LLVMIRBuilder::VisitFloat64Constant(AddrShift gate, double value) const { LLVMValueRef llvmValue = LLVMConstReal(LLVMDoubleType(), value); - LLVMTFBuilderBasicBlockImpl *impl = currentBb_->GetImpl(); - impl->values_[gate] = llvmValue; g_values[gate] = llvmValue; char *str = LLVMPrintValueToString(llvmValue); LOG_ECMA(INFO) << "VisitFloat64Constant set gate:" << gate << " value:" << value; @@ -706,8 +681,6 @@ void LLVMIRBuilder::VisitParameter(AddrShift gate) const int argth = circuit_->LoadGatePtrConst(gate)->GetBitField(); LOG_ECMA(INFO) << " Parameter value" << argth; LLVMValueRef value = LLVMGetParam(function_, argth); - LLVMTFBuilderBasicBlockImpl *impl = currentBb_->GetImpl(); - impl->values_[gate] = value; g_values[gate] = value; LOG_ECMA(INFO) << "VisitParameter set gate:" << gate << " value:" << value; // NOTE: caller put args, otherwise crash @@ -769,8 +742,7 @@ void LLVMIRBuilder::VisitFloatMod(AddrShift gate, AddrShift e1, AddrShift e2) co void LLVMIRBuilder::VisitBranch(AddrShift gate, AddrShift cmp, int btrue, int bfalse) { LOG_ECMA(INFO) << "cmp gate:" << cmp; - LLVMTFBuilderBasicBlockImpl *impl = EnsureLLVMBBImpl(currentBb_); - if ((impl->values_.count(cmp) == 0) && (g_values.count(cmp) == 0)) { + if (g_values.count(cmp) == 0) { LOG_ECMA(ERROR) << "Branch condition gate is nullptr!"; return; } @@ -1321,12 +1293,10 @@ void LLVMIRBuilder::VisitCastDoubleToInt(AddrShift gate, AddrShift e1) const LOG_ECMA(INFO) << "result: " << LLVMPrintValueToString(result); } -LLVMStubModule::LLVMStubModule(const char *name) +LLVMStubModule::LLVMStubModule(const char *name, const char *triple) { - module_ = LLVMModuleCreateWithName("fast_stubs"); -#ifdef PANDA_TARGET_AMD64 - LLVMSetTarget(module_, "x86_64-unknown-linux-gnu"); -#endif + module_ = LLVMModuleCreateWithName(name); + LLVMSetTarget(module_, triple); } void LLVMStubModule::Initialize() -- Gitee