From: Zack Rusin Date: Thu, 18 Oct 2007 11:20:27 +0000 (-0400) Subject: Fix some warnings and implement lg2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3ae767dd073e8c24fc159cb86f89e61ea7a0e85f;p=mesa.git Fix some warnings and implement lg2 --- diff --git a/src/mesa/pipe/llvm/instructions.cpp b/src/mesa/pipe/llvm/instructions.cpp index ee9104434ff..d43a617d35e 100644 --- a/src/mesa/pipe/llvm/instructions.cpp +++ b/src/mesa/pipe/llvm/instructions.cpp @@ -14,9 +14,10 @@ Instructions::Instructions(llvm::Module *mod, llvm::BasicBlock *block) m_floatVecType = VectorType::get(Type::FloatTy, 4); m_llvmFSqrt = 0; - m_llvmFAbs = 0; - m_llvmPow = 0; + m_llvmFAbs = 0; + m_llvmPow = 0; m_llvmFloor = 0; + m_llvmFlog = 0; } llvm::Value * Instructions::add(llvm::Value *in1, llvm::Value *in2) @@ -362,3 +363,53 @@ llvm::Value * Instructions::frc(llvm::Value *in) return sub(in, flr); } +llvm::Value * Instructions::callFLog(llvm::Value *val) +{ + if (!m_llvmFlog) { + // predeclare the intrinsic + std::vector flogArgs; + flogArgs.push_back(Type::FloatTy); + ParamAttrsList *flogPal = 0; + FunctionType* flogType = FunctionType::get( + /*Result=*/Type::FloatTy, + /*Params=*/flogArgs, + /*isVarArg=*/false, + /*ParamAttrs=*/flogPal); + m_llvmFlog = new Function( + /*Type=*/flogType, + /*Linkage=*/GlobalValue::ExternalLinkage, + /*Name=*/"logf", m_mod); + m_llvmFlog->setCallingConv(CallingConv::C); + } + CallInst *call = new CallInst(m_llvmFlog, val, + name("logf"), + m_block); + call->setCallingConv(CallingConv::C); + call->setTailCall(false); + return call; +} + +llvm::Value * Instructions::lg2(llvm::Value *in) +{ + ExtractElementInst *x = new ExtractElementInst(in, unsigned(0), + name("extractx"), + m_block); + ExtractElementInst *y = new ExtractElementInst(in, unsigned(1), + name("extracty"), + m_block); + ExtractElementInst *z = new ExtractElementInst(in, unsigned(2), + name("extractz"), + m_block); + ExtractElementInst *w = new ExtractElementInst(in, unsigned(3), + name("extractw"), + m_block); + llvm::Value *const_vec = vectorFromVals( + ConstantFP::get(Type::FloatTy, APFloat(1.442695f)), + ConstantFP::get(Type::FloatTy, APFloat(1.442695f)), + ConstantFP::get(Type::FloatTy, APFloat(1.442695f)), + ConstantFP::get(Type::FloatTy, APFloat(1.442695f)) + ); + return mul(vectorFromVals(callFLog(x), callFLog(y), + callFLog(z), callFLog(w)), const_vec); +} + diff --git a/src/mesa/pipe/llvm/instructions.h b/src/mesa/pipe/llvm/instructions.h index 17165ac9e70..e6ad47ebd28 100644 --- a/src/mesa/pipe/llvm/instructions.h +++ b/src/mesa/pipe/llvm/instructions.h @@ -19,16 +19,17 @@ public: llvm::Value *dp4(llvm::Value *in1, llvm::Value *in2); llvm::Value *dph(llvm::Value *in1, llvm::Value *in2); llvm::Value *dst(llvm::Value *in1, llvm::Value *in2); - llvm::Value *ex2(llvm::Value *in1); - llvm::Value *floor(llvm::Value *in1); - llvm::Value *frc(llvm::Value *in1); - llvm::Value *lit(llvm::Value *in1); + llvm::Value *ex2(llvm::Value *in); + llvm::Value *floor(llvm::Value *in); + llvm::Value *frc(llvm::Value *in); + llvm::Value *lit(llvm::Value *in); + llvm::Value *lg2(llvm::Value *in); llvm::Value *madd(llvm::Value *in1, llvm::Value *in2, llvm::Value *in2); llvm::Value *mul(llvm::Value *in1, llvm::Value *in2); llvm::Value *pow(llvm::Value *in1, llvm::Value *in2); - llvm::Value *rcp(llvm::Value *in1); - llvm::Value *rsq(llvm::Value *in1); + llvm::Value *rcp(llvm::Value *in); + llvm::Value *rsq(llvm::Value *in); llvm::Value *sub(llvm::Value *in1, llvm::Value *in2); private: const char *name(const char *prefix); @@ -36,6 +37,7 @@ private: llvm::Value *callFAbs(llvm::Value *val); llvm::Value *callFloor(llvm::Value *val); llvm::Value *callFSqrt(llvm::Value *val); + llvm::Value *callFLog(llvm::Value *val); llvm::Value *callPow(llvm::Value *val1, llvm::Value *val2); llvm::Value *vectorFromVals(llvm::Value *x, llvm::Value *y, @@ -52,6 +54,7 @@ private: llvm::Function *m_llvmFAbs; llvm::Function *m_llvmPow; llvm::Function *m_llvmFloor; + llvm::Function *m_llvmFlog; }; #endif diff --git a/src/mesa/pipe/llvm/llvm_base_shader.cpp b/src/mesa/pipe/llvm/llvm_base_shader.cpp new file mode 100644 index 00000000000..58dd57f6b9a --- /dev/null +++ b/src/mesa/pipe/llvm/llvm_base_shader.cpp @@ -0,0 +1,810 @@ +// Generated by llvm2cpp - DO NOT MODIFY! + + +Module* createBaseShader() { + // Module Construction + Module* mod = new Module("Shader"); + + // Type Definitions + ArrayType* ArrayTy_0 = ArrayType::get(IntegerType::get(8), 20); + + ArrayType* ArrayTy_2 = ArrayType::get(IntegerType::get(8), 31); + + std::vectorFuncTy_4_args; + VectorType* VectorTy_7 = VectorType::get(Type::FloatTy, 4); + + ArrayType* ArrayTy_6 = ArrayType::get(VectorTy_7, 16); + + PointerType* PointerTy_5 = PointerType::get(ArrayTy_6); + + FuncTy_4_args.push_back(PointerTy_5); + ArrayType* ArrayTy_10 = ArrayType::get(Type::FloatTy, 4); + + ArrayType* ArrayTy_9 = ArrayType::get(ArrayTy_10, 16); + + PointerType* PointerTy_8 = PointerType::get(ArrayTy_9); + + FuncTy_4_args.push_back(PointerTy_8); + FuncTy_4_args.push_back(IntegerType::get(32)); + FuncTy_4_args.push_back(IntegerType::get(32)); + ParamAttrsList *FuncTy_4_PAL = 0; + FunctionType* FuncTy_4 = FunctionType::get( + /*Result=*/Type::VoidTy, + /*Params=*/FuncTy_4_args, + /*isVarArg=*/false, + /*ParamAttrs=*/FuncTy_4_PAL); + + PointerType* PointerTy_12 = PointerType::get(VectorTy_7); + + std::vectorFuncTy_13_args; + FuncTy_13_args.push_back(PointerTy_12); + PointerType* PointerTy_14 = PointerType::get(ArrayTy_10); + + FuncTy_13_args.push_back(PointerTy_14); + FuncTy_13_args.push_back(IntegerType::get(32)); + ParamAttrsList *FuncTy_13_PAL = 0; + FunctionType* FuncTy_13 = FunctionType::get( + /*Result=*/Type::VoidTy, + /*Params=*/FuncTy_13_args, + /*isVarArg=*/false, + /*ParamAttrs=*/FuncTy_13_PAL); + + std::vectorFuncTy_15_args; + FuncTy_15_args.push_back(PointerTy_14); + FuncTy_15_args.push_back(PointerTy_12); + FuncTy_15_args.push_back(IntegerType::get(32)); + ParamAttrsList *FuncTy_15_PAL = 0; + FunctionType* FuncTy_15 = FunctionType::get( + /*Result=*/Type::VoidTy, + /*Params=*/FuncTy_15_args, + /*isVarArg=*/false, + /*ParamAttrs=*/FuncTy_15_PAL); + + std::vectorFuncTy_17_args; + ParamAttrsList *FuncTy_17_PAL = 0; + FunctionType* FuncTy_17 = FunctionType::get( + /*Result=*/IntegerType::get(32), + /*Params=*/FuncTy_17_args, + /*isVarArg=*/true, + /*ParamAttrs=*/FuncTy_17_PAL); + + std::vectorFuncTy_19_args; + FuncTy_19_args.push_back(PointerTy_8); + FuncTy_19_args.push_back(PointerTy_8); + FuncTy_19_args.push_back(PointerTy_14); + FuncTy_19_args.push_back(IntegerType::get(32)); + FuncTy_19_args.push_back(IntegerType::get(32)); + ParamAttrsList *FuncTy_19_PAL = 0; + FunctionType* FuncTy_19 = FunctionType::get( + /*Result=*/Type::VoidTy, + /*Params=*/FuncTy_19_args, + /*isVarArg=*/false, + /*ParamAttrs=*/FuncTy_19_PAL); + + ArrayType* ArrayTy_21 = ArrayType::get(ArrayTy_6, 2048); + + std::vectorFuncTy_23_args; + FuncTy_23_args.push_back(PointerTy_12); + FuncTy_23_args.push_back(PointerTy_12); + FuncTy_23_args.push_back(PointerTy_12); + ParamAttrsList *FuncTy_23_PAL = 0; + FunctionType* FuncTy_23 = FunctionType::get( + /*Result=*/Type::VoidTy, + /*Params=*/FuncTy_23_args, + /*isVarArg=*/false, + /*ParamAttrs=*/FuncTy_23_PAL); + + + // Function Declarations + + Function* func_from_array = new Function( + /*Type=*/FuncTy_4, + /*Linkage=*/GlobalValue::ExternalLinkage, + /*Name=*/"from_array", mod); + func_from_array->setCallingConv(CallingConv::C); + + Function* func_from_consts = new Function( + /*Type=*/FuncTy_13, + /*Linkage=*/GlobalValue::ExternalLinkage, + /*Name=*/"from_consts", mod); + func_from_consts->setCallingConv(CallingConv::C); + + Function* func_to_array = new Function( + /*Type=*/FuncTy_15, + /*Linkage=*/GlobalValue::ExternalLinkage, + /*Name=*/"to_array", mod); + func_to_array->setCallingConv(CallingConv::C); + + Function* func_printf = new Function( + /*Type=*/FuncTy_17, + /*Linkage=*/GlobalValue::ExternalLinkage, + /*Name=*/"printf", mod); // (external, no body) + func_printf->setCallingConv(CallingConv::C); + + Function* func_run_vertex_shader = new Function( + /*Type=*/FuncTy_19, + /*Linkage=*/GlobalValue::ExternalLinkage, + /*Name=*/"run_vertex_shader", mod); + func_run_vertex_shader->setCallingConv(CallingConv::C); + + Function* func_execute_shader = new Function( + /*Type=*/FuncTy_23, + /*Linkage=*/GlobalValue::ExternalLinkage, + /*Name=*/"execute_shader", mod); // (external, no body) + func_execute_shader->setCallingConv(CallingConv::C); + + // Global Variable Declarations + + + GlobalVariable* gvar_array__str = new GlobalVariable( + /*Type=*/ArrayTy_0, + /*isConstant=*/true, + /*Linkage=*/GlobalValue::InternalLinkage, + /*Initializer=*/0, // has initializer, specified below + /*Name=*/".str", + mod); + + GlobalVariable* gvar_array__str1 = new GlobalVariable( + /*Type=*/ArrayTy_2, + /*isConstant=*/true, + /*Linkage=*/GlobalValue::InternalLinkage, + /*Initializer=*/0, // has initializer, specified below + /*Name=*/".str1", + mod); + + // Constant Definitions + Constant* const_array_24 = ConstantArray::get("DEST = %f %f %f %f\x0A", true); + Constant* const_array_25 = ConstantArray::get("XXXXXXXXXXX run_vertex_shader\x0A", true); + Constant* const_int32_26 = Constant::getNullValue(IntegerType::get(32)); + UndefValue* const_packed_27 = UndefValue::get(VectorTy_7); + ConstantInt* const_int32_28 = ConstantInt::get(APInt(32, "1", 10)); + ConstantInt* const_int32_29 = ConstantInt::get(APInt(32, "2", 10)); + ConstantInt* const_int32_30 = ConstantInt::get(APInt(32, "3", 10)); + std::vector const_ptr_31_indices; + const_ptr_31_indices.push_back(const_int32_26); + const_ptr_31_indices.push_back(const_int32_26); + Constant* const_ptr_31 = ConstantExpr::getGetElementPtr(gvar_array__str, &const_ptr_31_indices[0], const_ptr_31_indices.size() ); + std::vector const_ptr_32_indices; + const_ptr_32_indices.push_back(const_int32_26); + const_ptr_32_indices.push_back(const_int32_26); + Constant* const_ptr_32 = ConstantExpr::getGetElementPtr(gvar_array__str1, &const_ptr_32_indices[0], const_ptr_32_indices.size() ); + ConstantInt* const_int32_33 = ConstantInt::get(APInt(32, "4", 10)); + + // Global Variable Definitions + gvar_array__str->setInitializer(const_array_24); + gvar_array__str1->setInitializer(const_array_25); + + // Function Definitions + + // Function: from_array (func_from_array) + { + Function::arg_iterator args = func_from_array->arg_begin(); + Value* ptr_res = args++; + ptr_res->setName("res"); + Value* ptr_ainputs = args++; + ptr_ainputs->setName("ainputs"); + Value* int32_count = args++; + int32_count->setName("count"); + Value* int32_num_attribs = args++; + int32_num_attribs->setName("num_attribs"); + + BasicBlock* label_entry = new BasicBlock("entry",func_from_array,0); + BasicBlock* label_forbody6 = new BasicBlock("forbody6",func_from_array,0); + BasicBlock* label_forinc57 = new BasicBlock("forinc57",func_from_array,0); + BasicBlock* label_afterfor60 = new BasicBlock("afterfor60",func_from_array,0); + + // Block entry (label_entry) + ICmpInst* int1_cmp = new ICmpInst(ICmpInst::ICMP_SGT, int32_count, const_int32_26, "cmp", label_entry); + ICmpInst* int1_cmp5 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_attribs, const_int32_26, "cmp5", label_entry); + BinaryOperator* int1_bothcond = BinaryOperator::create(Instruction::And, int1_cmp, int1_cmp5, "bothcond", label_entry); + new BranchInst(label_forbody6, label_afterfor60, int1_bothcond, label_entry); + + // Block forbody6 (label_forbody6) + Argument* fwdref_35 = new Argument(IntegerType::get(32)); + Argument* fwdref_36 = new Argument(IntegerType::get(32)); + PHINode* int32_i_013_0 = new PHINode(IntegerType::get(32), "i.013.0", label_forbody6); + int32_i_013_0->reserveOperandSpace(3); + int32_i_013_0->addIncoming(const_int32_26, label_entry); + int32_i_013_0->addIncoming(fwdref_35, label_forinc57); + int32_i_013_0->addIncoming(fwdref_36, label_forbody6); + + Argument* fwdref_37 = new Argument(IntegerType::get(32)); + PHINode* int32_j_03_0 = new PHINode(IntegerType::get(32), "j.03.0", label_forbody6); + int32_j_03_0->reserveOperandSpace(3); + int32_j_03_0->addIncoming(fwdref_37, label_forbody6); + int32_j_03_0->addIncoming(const_int32_26, label_forinc57); + int32_j_03_0->addIncoming(const_int32_26, label_entry); + + Argument* fwdref_38 = new Argument(VectorTy_7); + PHINode* packed_vec_01_0 = new PHINode(VectorTy_7, "vec.01.0", label_forbody6); + packed_vec_01_0->reserveOperandSpace(3); + packed_vec_01_0->addIncoming(fwdref_38, label_forbody6); + packed_vec_01_0->addIncoming(const_packed_27, label_entry); + packed_vec_01_0->addIncoming(fwdref_38, label_forinc57); + + std::vector ptr_arraydecay11_indices; + ptr_arraydecay11_indices.push_back(int32_i_013_0); + ptr_arraydecay11_indices.push_back(int32_j_03_0); + ptr_arraydecay11_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay11 = new GetElementPtrInst(ptr_ainputs, ptr_arraydecay11_indices.begin(), ptr_arraydecay11_indices.end(), "arraydecay11", label_forbody6); + LoadInst* float_tmp13 = new LoadInst(ptr_arraydecay11, "tmp13", false, label_forbody6); + InsertElementInst* packed_tmp15 = new InsertElementInst(packed_vec_01_0, float_tmp13, const_int32_26, "tmp15", label_forbody6); + std::vector ptr_arrayidx23_indices; + ptr_arrayidx23_indices.push_back(int32_i_013_0); + ptr_arrayidx23_indices.push_back(int32_j_03_0); + ptr_arrayidx23_indices.push_back(const_int32_28); + Instruction* ptr_arrayidx23 = new GetElementPtrInst(ptr_ainputs, ptr_arrayidx23_indices.begin(), ptr_arrayidx23_indices.end(), "arrayidx23", label_forbody6); + LoadInst* float_tmp24 = new LoadInst(ptr_arrayidx23, "tmp24", false, label_forbody6); + InsertElementInst* packed_tmp26 = new InsertElementInst(packed_tmp15, float_tmp24, const_int32_28, "tmp26", label_forbody6); + std::vector ptr_arrayidx34_indices; + ptr_arrayidx34_indices.push_back(int32_i_013_0); + ptr_arrayidx34_indices.push_back(int32_j_03_0); + ptr_arrayidx34_indices.push_back(const_int32_29); + Instruction* ptr_arrayidx34 = new GetElementPtrInst(ptr_ainputs, ptr_arrayidx34_indices.begin(), ptr_arrayidx34_indices.end(), "arrayidx34", label_forbody6); + LoadInst* float_tmp35 = new LoadInst(ptr_arrayidx34, "tmp35", false, label_forbody6); + InsertElementInst* packed_tmp37 = new InsertElementInst(packed_tmp26, float_tmp35, const_int32_29, "tmp37", label_forbody6); + std::vector ptr_arrayidx45_indices; + ptr_arrayidx45_indices.push_back(int32_i_013_0); + ptr_arrayidx45_indices.push_back(int32_j_03_0); + ptr_arrayidx45_indices.push_back(const_int32_30); + Instruction* ptr_arrayidx45 = new GetElementPtrInst(ptr_ainputs, ptr_arrayidx45_indices.begin(), ptr_arrayidx45_indices.end(), "arrayidx45", label_forbody6); + LoadInst* float_tmp46 = new LoadInst(ptr_arrayidx45, "tmp46", false, label_forbody6); + InsertElementInst* packed_tmp48 = new InsertElementInst(packed_tmp37, float_tmp46, const_int32_30, "tmp48", label_forbody6); + std::vector ptr_arrayidx54_indices; + ptr_arrayidx54_indices.push_back(int32_i_013_0); + ptr_arrayidx54_indices.push_back(int32_j_03_0); + Instruction* ptr_arrayidx54 = new GetElementPtrInst(ptr_res, ptr_arrayidx54_indices.begin(), ptr_arrayidx54_indices.end(), "arrayidx54", label_forbody6); + new StoreInst(packed_tmp48, ptr_arrayidx54, false, label_forbody6); + BinaryOperator* int32_inc = BinaryOperator::create(Instruction::Add, int32_j_03_0, const_int32_28, "inc", label_forbody6); + ICmpInst* int1_cmp511 = new ICmpInst(ICmpInst::ICMP_SLT, int32_inc, int32_num_attribs, "cmp511", label_forbody6); + new BranchInst(label_forbody6, label_forinc57, int1_cmp511, label_forbody6); + + // Block forinc57 (label_forinc57) + BinaryOperator* int32_inc59 = BinaryOperator::create(Instruction::Add, int32_i_013_0, const_int32_28, "inc59", label_forinc57); + ICmpInst* int1_cmp21 = new ICmpInst(ICmpInst::ICMP_SLT, int32_inc59, int32_count, "cmp21", label_forinc57); + new BranchInst(label_forbody6, label_afterfor60, int1_cmp21, label_forinc57); + + // Block afterfor60 (label_afterfor60) + new ReturnInst(label_afterfor60); + + // Resolve Forward References + fwdref_36->replaceAllUsesWith(int32_i_013_0); delete fwdref_36; + fwdref_38->replaceAllUsesWith(packed_tmp48); delete fwdref_38; + fwdref_37->replaceAllUsesWith(int32_inc); delete fwdref_37; + fwdref_35->replaceAllUsesWith(int32_inc59); delete fwdref_35; + + } + + // Function: from_consts (func_from_consts) + { + Function::arg_iterator args = func_from_consts->arg_begin(); + Value* ptr_res_43 = args++; + ptr_res_43->setName("res"); + Value* ptr_ainputs_44 = args++; + ptr_ainputs_44->setName("ainputs"); + Value* int32_count_45 = args++; + int32_count_45->setName("count"); + + BasicBlock* label_entry_46 = new BasicBlock("entry",func_from_consts,0); + BasicBlock* label_forbody = new BasicBlock("forbody",func_from_consts,0); + BasicBlock* label_afterfor = new BasicBlock("afterfor",func_from_consts,0); + + // Block entry (label_entry_46) + ICmpInst* int1_cmp_47 = new ICmpInst(ICmpInst::ICMP_SGT, int32_count_45, const_int32_26, "cmp", label_entry_46); + new BranchInst(label_forbody, label_afterfor, int1_cmp_47, label_entry_46); + + // Block forbody (label_forbody) + Argument* fwdref_49 = new Argument(IntegerType::get(32)); + PHINode* int32_i_02_0 = new PHINode(IntegerType::get(32), "i.02.0", label_forbody); + int32_i_02_0->reserveOperandSpace(2); + int32_i_02_0->addIncoming(const_int32_26, label_entry_46); + int32_i_02_0->addIncoming(fwdref_49, label_forbody); + + Argument* fwdref_51 = new Argument(VectorTy_7); + PHINode* packed_vec_01_0_50 = new PHINode(VectorTy_7, "vec.01.0", label_forbody); + packed_vec_01_0_50->reserveOperandSpace(2); + packed_vec_01_0_50->addIncoming(const_packed_27, label_entry_46); + packed_vec_01_0_50->addIncoming(fwdref_51, label_forbody); + + std::vector ptr_arraydecay_indices; + ptr_arraydecay_indices.push_back(int32_i_02_0); + ptr_arraydecay_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay = new GetElementPtrInst(ptr_ainputs_44, ptr_arraydecay_indices.begin(), ptr_arraydecay_indices.end(), "arraydecay", label_forbody); + LoadInst* float_tmp5 = new LoadInst(ptr_arraydecay, "tmp5", false, label_forbody); + InsertElementInst* packed_tmp7 = new InsertElementInst(packed_vec_01_0_50, float_tmp5, const_int32_26, "tmp7", label_forbody); + std::vector ptr_arrayidx12_indices; + ptr_arrayidx12_indices.push_back(int32_i_02_0); + ptr_arrayidx12_indices.push_back(const_int32_28); + Instruction* ptr_arrayidx12 = new GetElementPtrInst(ptr_ainputs_44, ptr_arrayidx12_indices.begin(), ptr_arrayidx12_indices.end(), "arrayidx12", label_forbody); + LoadInst* float_tmp13_52 = new LoadInst(ptr_arrayidx12, "tmp13", false, label_forbody); + InsertElementInst* packed_tmp15_53 = new InsertElementInst(packed_tmp7, float_tmp13_52, const_int32_28, "tmp15", label_forbody); + std::vector ptr_arrayidx20_indices; + ptr_arrayidx20_indices.push_back(int32_i_02_0); + ptr_arrayidx20_indices.push_back(const_int32_29); + Instruction* ptr_arrayidx20 = new GetElementPtrInst(ptr_ainputs_44, ptr_arrayidx20_indices.begin(), ptr_arrayidx20_indices.end(), "arrayidx20", label_forbody); + LoadInst* float_tmp21 = new LoadInst(ptr_arrayidx20, "tmp21", false, label_forbody); + InsertElementInst* packed_tmp23 = new InsertElementInst(packed_tmp15_53, float_tmp21, const_int32_29, "tmp23", label_forbody); + std::vector ptr_arrayidx28_indices; + ptr_arrayidx28_indices.push_back(int32_i_02_0); + ptr_arrayidx28_indices.push_back(const_int32_30); + Instruction* ptr_arrayidx28 = new GetElementPtrInst(ptr_ainputs_44, ptr_arrayidx28_indices.begin(), ptr_arrayidx28_indices.end(), "arrayidx28", label_forbody); + LoadInst* float_tmp29 = new LoadInst(ptr_arrayidx28, "tmp29", false, label_forbody); + InsertElementInst* packed_tmp31 = new InsertElementInst(packed_tmp23, float_tmp29, const_int32_30, "tmp31", label_forbody); + GetElementPtrInst* ptr_arrayidx34_54 = new GetElementPtrInst(ptr_res_43, int32_i_02_0, "arrayidx34", label_forbody); + new StoreInst(packed_tmp31, ptr_arrayidx34_54, false, label_forbody); + BinaryOperator* int32_indvar_next = BinaryOperator::create(Instruction::Add, int32_i_02_0, const_int32_28, "indvar.next", label_forbody); + ICmpInst* int1_exitcond = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next, int32_count_45, "exitcond", label_forbody); + new BranchInst(label_afterfor, label_forbody, int1_exitcond, label_forbody); + + // Block afterfor (label_afterfor) + new ReturnInst(label_afterfor); + + // Resolve Forward References + fwdref_51->replaceAllUsesWith(packed_tmp31); delete fwdref_51; + fwdref_49->replaceAllUsesWith(int32_indvar_next); delete fwdref_49; + + } + + // Function: to_array (func_to_array) + { + Function::arg_iterator args = func_to_array->arg_begin(); + Value* ptr_dests = args++; + ptr_dests->setName("dests"); + Value* ptr_in = args++; + ptr_in->setName("in"); + Value* int32_num_attribs_58 = args++; + int32_num_attribs_58->setName("num_attribs"); + + BasicBlock* label_entry_59 = new BasicBlock("entry",func_to_array,0); + BasicBlock* label_forbody_60 = new BasicBlock("forbody",func_to_array,0); + BasicBlock* label_afterfor_61 = new BasicBlock("afterfor",func_to_array,0); + + // Block entry (label_entry_59) + ICmpInst* int1_cmp_62 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_attribs_58, const_int32_26, "cmp", label_entry_59); + new BranchInst(label_forbody_60, label_afterfor_61, int1_cmp_62, label_entry_59); + + // Block forbody (label_forbody_60) + Argument* fwdref_64 = new Argument(IntegerType::get(32)); + PHINode* int32_i_01_0 = new PHINode(IntegerType::get(32), "i.01.0", label_forbody_60); + int32_i_01_0->reserveOperandSpace(2); + int32_i_01_0->addIncoming(const_int32_26, label_entry_59); + int32_i_01_0->addIncoming(fwdref_64, label_forbody_60); + + std::vector ptr_arraydecay_65_indices; + ptr_arraydecay_65_indices.push_back(int32_i_01_0); + ptr_arraydecay_65_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay_65 = new GetElementPtrInst(ptr_dests, ptr_arraydecay_65_indices.begin(), ptr_arraydecay_65_indices.end(), "arraydecay", label_forbody_60); + GetElementPtrInst* ptr_arrayidx6 = new GetElementPtrInst(ptr_in, int32_i_01_0, "arrayidx6", label_forbody_60); + LoadInst* packed_tmp7_66 = new LoadInst(ptr_arrayidx6, "tmp7", false, label_forbody_60); + ExtractElementInst* float_tmp9 = new ExtractElementInst(packed_tmp7_66, const_int32_26, "tmp9", label_forbody_60); + CastInst* double_conv = new FPExtInst(float_tmp9, Type::DoubleTy, "conv", label_forbody_60); + ExtractElementInst* float_tmp11 = new ExtractElementInst(packed_tmp7_66, const_int32_28, "tmp11", label_forbody_60); + CastInst* double_conv12 = new FPExtInst(float_tmp11, Type::DoubleTy, "conv12", label_forbody_60); + ExtractElementInst* float_tmp14 = new ExtractElementInst(packed_tmp7_66, const_int32_29, "tmp14", label_forbody_60); + CastInst* double_conv15 = new FPExtInst(float_tmp14, Type::DoubleTy, "conv15", label_forbody_60); + ExtractElementInst* float_tmp17 = new ExtractElementInst(packed_tmp7_66, const_int32_30, "tmp17", label_forbody_60); + CastInst* double_conv18 = new FPExtInst(float_tmp17, Type::DoubleTy, "conv18", label_forbody_60); + std::vector int32_call_params; + int32_call_params.push_back(const_ptr_31); + int32_call_params.push_back(double_conv); + int32_call_params.push_back(double_conv12); + int32_call_params.push_back(double_conv15); + int32_call_params.push_back(double_conv18); + CallInst* int32_call = new CallInst(func_printf, int32_call_params.begin(), int32_call_params.end(), "call", label_forbody_60); + int32_call->setCallingConv(CallingConv::C); + int32_call->setTailCall(true); + new StoreInst(float_tmp9, ptr_arraydecay_65, false, label_forbody_60); + std::vector ptr_arrayidx24_indices; + ptr_arrayidx24_indices.push_back(int32_i_01_0); + ptr_arrayidx24_indices.push_back(const_int32_28); + Instruction* ptr_arrayidx24 = new GetElementPtrInst(ptr_dests, ptr_arrayidx24_indices.begin(), ptr_arrayidx24_indices.end(), "arrayidx24", label_forbody_60); + new StoreInst(float_tmp11, ptr_arrayidx24, false, label_forbody_60); + std::vector ptr_arrayidx28_69_indices; + ptr_arrayidx28_69_indices.push_back(int32_i_01_0); + ptr_arrayidx28_69_indices.push_back(const_int32_29); + Instruction* ptr_arrayidx28_69 = new GetElementPtrInst(ptr_dests, ptr_arrayidx28_69_indices.begin(), ptr_arrayidx28_69_indices.end(), "arrayidx28", label_forbody_60); + new StoreInst(float_tmp14, ptr_arrayidx28_69, false, label_forbody_60); + std::vector ptr_arrayidx32_indices; + ptr_arrayidx32_indices.push_back(int32_i_01_0); + ptr_arrayidx32_indices.push_back(const_int32_30); + Instruction* ptr_arrayidx32 = new GetElementPtrInst(ptr_dests, ptr_arrayidx32_indices.begin(), ptr_arrayidx32_indices.end(), "arrayidx32", label_forbody_60); + new StoreInst(float_tmp17, ptr_arrayidx32, false, label_forbody_60); + BinaryOperator* int32_indvar_next_72 = BinaryOperator::create(Instruction::Add, int32_i_01_0, const_int32_28, "indvar.next", label_forbody_60); + ICmpInst* int1_exitcond_73 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_72, int32_num_attribs_58, "exitcond", label_forbody_60); + new BranchInst(label_afterfor_61, label_forbody_60, int1_exitcond_73, label_forbody_60); + + // Block afterfor (label_afterfor_61) + new ReturnInst(label_afterfor_61); + + // Resolve Forward References + fwdref_64->replaceAllUsesWith(int32_indvar_next_72); delete fwdref_64; + + } + + // Function: run_vertex_shader (func_run_vertex_shader) + { + Function::arg_iterator args = func_run_vertex_shader->arg_begin(); + Value* ptr_ainputs_76 = args++; + ptr_ainputs_76->setName("ainputs"); + Value* ptr_dests_77 = args++; + ptr_dests_77->setName("dests"); + Value* ptr_aconsts = args++; + ptr_aconsts->setName("aconsts"); + Value* int32_count_78 = args++; + int32_count_78->setName("count"); + Value* int32_num_attribs_79 = args++; + int32_num_attribs_79->setName("num_attribs"); + + BasicBlock* label_entry_80 = new BasicBlock("entry",func_run_vertex_shader,0); + BasicBlock* label_forbody6_i = new BasicBlock("forbody6.i",func_run_vertex_shader,0); + BasicBlock* label_forinc57_i = new BasicBlock("forinc57.i",func_run_vertex_shader,0); + BasicBlock* label_forbody_i11_preheader = new BasicBlock("forbody.i11.preheader",func_run_vertex_shader,0); + BasicBlock* label_forbody_preheader = new BasicBlock("forbody.preheader",func_run_vertex_shader,0); + BasicBlock* label_forbody_us = new BasicBlock("forbody.us",func_run_vertex_shader,0); + BasicBlock* label_to_array_exit_us = new BasicBlock("to_array.exit.us",func_run_vertex_shader,0); + BasicBlock* label_forbody_i_us = new BasicBlock("forbody.i.us",func_run_vertex_shader,0); + BasicBlock* label_forbody_81 = new BasicBlock("forbody",func_run_vertex_shader,0); + BasicBlock* label_afterfor_82 = new BasicBlock("afterfor",func_run_vertex_shader,0); + + // Block entry (label_entry_80) + AllocaInst* ptr_inputs = new AllocaInst(ArrayTy_21, "inputs", label_entry_80); + AllocaInst* ptr_consts = new AllocaInst(ArrayTy_6, "consts", label_entry_80); + AllocaInst* ptr_results = new AllocaInst(ArrayTy_21, "results", label_entry_80); + CallInst* int32_call_83 = new CallInst(func_printf, const_ptr_32, "call", label_entry_80); + int32_call_83->setCallingConv(CallingConv::C); + int32_call_83->setTailCall(false); + ICmpInst* int1_cmp_i = new ICmpInst(ICmpInst::ICMP_SGT, int32_count_78, const_int32_26, "cmp.i", label_entry_80); + ICmpInst* int1_cmp5_i = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_attribs_79, const_int32_26, "cmp5.i", label_entry_80); + BinaryOperator* int1_bothcond_i = BinaryOperator::create(Instruction::And, int1_cmp5_i, int1_cmp_i, "bothcond.i", label_entry_80); + new BranchInst(label_forbody6_i, label_forbody_i11_preheader, int1_bothcond_i, label_entry_80); + + // Block forbody6.i (label_forbody6_i) + Argument* fwdref_85 = new Argument(IntegerType::get(32)); + Argument* fwdref_86 = new Argument(IntegerType::get(32)); + PHINode* int32_i_013_0_i_ph = new PHINode(IntegerType::get(32), "i.013.0.i.ph", label_forbody6_i); + int32_i_013_0_i_ph->reserveOperandSpace(3); + int32_i_013_0_i_ph->addIncoming(const_int32_26, label_entry_80); + int32_i_013_0_i_ph->addIncoming(fwdref_85, label_forinc57_i); + int32_i_013_0_i_ph->addIncoming(fwdref_86, label_forbody6_i); + + Argument* fwdref_87 = new Argument(IntegerType::get(32)); + PHINode* int32_j_03_0_i = new PHINode(IntegerType::get(32), "j.03.0.i", label_forbody6_i); + int32_j_03_0_i->reserveOperandSpace(3); + int32_j_03_0_i->addIncoming(fwdref_87, label_forbody6_i); + int32_j_03_0_i->addIncoming(const_int32_26, label_forinc57_i); + int32_j_03_0_i->addIncoming(const_int32_26, label_entry_80); + + Argument* fwdref_88 = new Argument(VectorTy_7); + PHINode* packed_vec_01_0_i = new PHINode(VectorTy_7, "vec.01.0.i", label_forbody6_i); + packed_vec_01_0_i->reserveOperandSpace(3); + packed_vec_01_0_i->addIncoming(fwdref_88, label_forbody6_i); + packed_vec_01_0_i->addIncoming(const_packed_27, label_entry_80); + packed_vec_01_0_i->addIncoming(fwdref_88, label_forinc57_i); + + std::vector ptr_arraydecay11_i_indices; + ptr_arraydecay11_i_indices.push_back(int32_i_013_0_i_ph); + ptr_arraydecay11_i_indices.push_back(int32_j_03_0_i); + ptr_arraydecay11_i_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay11_i = new GetElementPtrInst(ptr_ainputs_76, ptr_arraydecay11_i_indices.begin(), ptr_arraydecay11_i_indices.end(), "arraydecay11.i", label_forbody6_i); + LoadInst* float_tmp13_i = new LoadInst(ptr_arraydecay11_i, "tmp13.i", false, label_forbody6_i); + InsertElementInst* packed_tmp15_i = new InsertElementInst(packed_vec_01_0_i, float_tmp13_i, const_int32_26, "tmp15.i", label_forbody6_i); + std::vector ptr_arrayidx23_i_indices; + ptr_arrayidx23_i_indices.push_back(int32_i_013_0_i_ph); + ptr_arrayidx23_i_indices.push_back(int32_j_03_0_i); + ptr_arrayidx23_i_indices.push_back(const_int32_28); + Instruction* ptr_arrayidx23_i = new GetElementPtrInst(ptr_ainputs_76, ptr_arrayidx23_i_indices.begin(), ptr_arrayidx23_i_indices.end(), "arrayidx23.i", label_forbody6_i); + LoadInst* float_tmp24_i = new LoadInst(ptr_arrayidx23_i, "tmp24.i", false, label_forbody6_i); + InsertElementInst* packed_tmp26_i = new InsertElementInst(packed_tmp15_i, float_tmp24_i, const_int32_28, "tmp26.i", label_forbody6_i); + std::vector ptr_arrayidx34_i_indices; + ptr_arrayidx34_i_indices.push_back(int32_i_013_0_i_ph); + ptr_arrayidx34_i_indices.push_back(int32_j_03_0_i); + ptr_arrayidx34_i_indices.push_back(const_int32_29); + Instruction* ptr_arrayidx34_i = new GetElementPtrInst(ptr_ainputs_76, ptr_arrayidx34_i_indices.begin(), ptr_arrayidx34_i_indices.end(), "arrayidx34.i", label_forbody6_i); + LoadInst* float_tmp35_i = new LoadInst(ptr_arrayidx34_i, "tmp35.i", false, label_forbody6_i); + InsertElementInst* packed_tmp37_i = new InsertElementInst(packed_tmp26_i, float_tmp35_i, const_int32_29, "tmp37.i", label_forbody6_i); + std::vector ptr_arrayidx45_i_indices; + ptr_arrayidx45_i_indices.push_back(int32_i_013_0_i_ph); + ptr_arrayidx45_i_indices.push_back(int32_j_03_0_i); + ptr_arrayidx45_i_indices.push_back(const_int32_30); + Instruction* ptr_arrayidx45_i = new GetElementPtrInst(ptr_ainputs_76, ptr_arrayidx45_i_indices.begin(), ptr_arrayidx45_i_indices.end(), "arrayidx45.i", label_forbody6_i); + LoadInst* float_tmp46_i = new LoadInst(ptr_arrayidx45_i, "tmp46.i", false, label_forbody6_i); + InsertElementInst* packed_tmp48_i = new InsertElementInst(packed_tmp37_i, float_tmp46_i, const_int32_30, "tmp48.i", label_forbody6_i); + std::vector ptr_arrayidx54_i_indices; + ptr_arrayidx54_i_indices.push_back(const_int32_26); + ptr_arrayidx54_i_indices.push_back(int32_i_013_0_i_ph); + ptr_arrayidx54_i_indices.push_back(int32_j_03_0_i); + Instruction* ptr_arrayidx54_i = new GetElementPtrInst(ptr_inputs, ptr_arrayidx54_i_indices.begin(), ptr_arrayidx54_i_indices.end(), "arrayidx54.i", label_forbody6_i); + new StoreInst(packed_tmp48_i, ptr_arrayidx54_i, false, label_forbody6_i); + BinaryOperator* int32_inc_i = BinaryOperator::create(Instruction::Add, int32_j_03_0_i, const_int32_28, "inc.i", label_forbody6_i); + ICmpInst* int1_cmp511_i = new ICmpInst(ICmpInst::ICMP_SLT, int32_inc_i, int32_num_attribs_79, "cmp511.i", label_forbody6_i); + new BranchInst(label_forbody6_i, label_forinc57_i, int1_cmp511_i, label_forbody6_i); + + // Block forinc57.i (label_forinc57_i) + BinaryOperator* int32_inc59_i = BinaryOperator::create(Instruction::Add, int32_i_013_0_i_ph, const_int32_28, "inc59.i", label_forinc57_i); + ICmpInst* int1_cmp21_i = new ICmpInst(ICmpInst::ICMP_SLT, int32_inc59_i, int32_count_78, "cmp21.i", label_forinc57_i); + new BranchInst(label_forbody6_i, label_forbody_i11_preheader, int1_cmp21_i, label_forinc57_i); + + // Block forbody.i11.preheader (label_forbody_i11_preheader) + std::vector ptr_arraydecay_i3_indices; + ptr_arraydecay_i3_indices.push_back(const_int32_26); + ptr_arraydecay_i3_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay_i3 = new GetElementPtrInst(ptr_aconsts, ptr_arraydecay_i3_indices.begin(), ptr_arraydecay_i3_indices.end(), "arraydecay.i3", label_forbody_i11_preheader); + LoadInst* float_tmp5_i = new LoadInst(ptr_arraydecay_i3, "tmp5.i", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp7_i4 = new InsertElementInst(const_packed_27, float_tmp5_i, const_int32_26, "tmp7.i4", label_forbody_i11_preheader); + std::vector ptr_arrayidx12_i_indices; + ptr_arrayidx12_i_indices.push_back(const_int32_26); + ptr_arrayidx12_i_indices.push_back(const_int32_28); + Instruction* ptr_arrayidx12_i = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx12_i_indices.begin(), ptr_arrayidx12_i_indices.end(), "arrayidx12.i", label_forbody_i11_preheader); + LoadInst* float_tmp13_i5 = new LoadInst(ptr_arrayidx12_i, "tmp13.i5", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp15_i6 = new InsertElementInst(packed_tmp7_i4, float_tmp13_i5, const_int32_28, "tmp15.i6", label_forbody_i11_preheader); + std::vector ptr_arrayidx20_i_indices; + ptr_arrayidx20_i_indices.push_back(const_int32_26); + ptr_arrayidx20_i_indices.push_back(const_int32_29); + Instruction* ptr_arrayidx20_i = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx20_i_indices.begin(), ptr_arrayidx20_i_indices.end(), "arrayidx20.i", label_forbody_i11_preheader); + LoadInst* float_tmp21_i = new LoadInst(ptr_arrayidx20_i, "tmp21.i", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp23_i = new InsertElementInst(packed_tmp15_i6, float_tmp21_i, const_int32_29, "tmp23.i", label_forbody_i11_preheader); + std::vector ptr_arrayidx28_i7_indices; + ptr_arrayidx28_i7_indices.push_back(const_int32_26); + ptr_arrayidx28_i7_indices.push_back(const_int32_30); + Instruction* ptr_arrayidx28_i7 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx28_i7_indices.begin(), ptr_arrayidx28_i7_indices.end(), "arrayidx28.i7", label_forbody_i11_preheader); + LoadInst* float_tmp29_i = new LoadInst(ptr_arrayidx28_i7, "tmp29.i", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp31_i = new InsertElementInst(packed_tmp23_i, float_tmp29_i, const_int32_30, "tmp31.i", label_forbody_i11_preheader); + std::vector ptr_arrayidx34_i8_indices; + ptr_arrayidx34_i8_indices.push_back(const_int32_26); + ptr_arrayidx34_i8_indices.push_back(const_int32_26); + Instruction* ptr_arrayidx34_i8 = new GetElementPtrInst(ptr_consts, ptr_arrayidx34_i8_indices.begin(), ptr_arrayidx34_i8_indices.end(), "arrayidx34.i8", label_forbody_i11_preheader); + new StoreInst(packed_tmp31_i, ptr_arrayidx34_i8, false, label_forbody_i11_preheader); + std::vector ptr_arraydecay_i3_1_indices; + ptr_arraydecay_i3_1_indices.push_back(const_int32_28); + ptr_arraydecay_i3_1_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay_i3_1 = new GetElementPtrInst(ptr_aconsts, ptr_arraydecay_i3_1_indices.begin(), ptr_arraydecay_i3_1_indices.end(), "arraydecay.i3.1", label_forbody_i11_preheader); + LoadInst* float_tmp5_i_1 = new LoadInst(ptr_arraydecay_i3_1, "tmp5.i.1", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp7_i4_1 = new InsertElementInst(packed_tmp31_i, float_tmp5_i_1, const_int32_26, "tmp7.i4.1", label_forbody_i11_preheader); + std::vector ptr_arrayidx12_i_1_indices; + ptr_arrayidx12_i_1_indices.push_back(const_int32_28); + ptr_arrayidx12_i_1_indices.push_back(const_int32_28); + Instruction* ptr_arrayidx12_i_1 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx12_i_1_indices.begin(), ptr_arrayidx12_i_1_indices.end(), "arrayidx12.i.1", label_forbody_i11_preheader); + LoadInst* float_tmp13_i5_1 = new LoadInst(ptr_arrayidx12_i_1, "tmp13.i5.1", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp15_i6_1 = new InsertElementInst(packed_tmp7_i4_1, float_tmp13_i5_1, const_int32_28, "tmp15.i6.1", label_forbody_i11_preheader); + std::vector ptr_arrayidx20_i_1_indices; + ptr_arrayidx20_i_1_indices.push_back(const_int32_28); + ptr_arrayidx20_i_1_indices.push_back(const_int32_29); + Instruction* ptr_arrayidx20_i_1 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx20_i_1_indices.begin(), ptr_arrayidx20_i_1_indices.end(), "arrayidx20.i.1", label_forbody_i11_preheader); + LoadInst* float_tmp21_i_1 = new LoadInst(ptr_arrayidx20_i_1, "tmp21.i.1", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp23_i_1 = new InsertElementInst(packed_tmp15_i6_1, float_tmp21_i_1, const_int32_29, "tmp23.i.1", label_forbody_i11_preheader); + std::vector ptr_arrayidx28_i7_1_indices; + ptr_arrayidx28_i7_1_indices.push_back(const_int32_28); + ptr_arrayidx28_i7_1_indices.push_back(const_int32_30); + Instruction* ptr_arrayidx28_i7_1 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx28_i7_1_indices.begin(), ptr_arrayidx28_i7_1_indices.end(), "arrayidx28.i7.1", label_forbody_i11_preheader); + LoadInst* float_tmp29_i_1 = new LoadInst(ptr_arrayidx28_i7_1, "tmp29.i.1", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp31_i_1 = new InsertElementInst(packed_tmp23_i_1, float_tmp29_i_1, const_int32_30, "tmp31.i.1", label_forbody_i11_preheader); + std::vector ptr_arrayidx34_i8_1_indices; + ptr_arrayidx34_i8_1_indices.push_back(const_int32_26); + ptr_arrayidx34_i8_1_indices.push_back(const_int32_28); + Instruction* ptr_arrayidx34_i8_1 = new GetElementPtrInst(ptr_consts, ptr_arrayidx34_i8_1_indices.begin(), ptr_arrayidx34_i8_1_indices.end(), "arrayidx34.i8.1", label_forbody_i11_preheader); + new StoreInst(packed_tmp31_i_1, ptr_arrayidx34_i8_1, false, label_forbody_i11_preheader); + std::vector ptr_arraydecay_i3_2_indices; + ptr_arraydecay_i3_2_indices.push_back(const_int32_29); + ptr_arraydecay_i3_2_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay_i3_2 = new GetElementPtrInst(ptr_aconsts, ptr_arraydecay_i3_2_indices.begin(), ptr_arraydecay_i3_2_indices.end(), "arraydecay.i3.2", label_forbody_i11_preheader); + LoadInst* float_tmp5_i_2 = new LoadInst(ptr_arraydecay_i3_2, "tmp5.i.2", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp7_i4_2 = new InsertElementInst(packed_tmp31_i_1, float_tmp5_i_2, const_int32_26, "tmp7.i4.2", label_forbody_i11_preheader); + std::vector ptr_arrayidx12_i_2_indices; + ptr_arrayidx12_i_2_indices.push_back(const_int32_29); + ptr_arrayidx12_i_2_indices.push_back(const_int32_28); + Instruction* ptr_arrayidx12_i_2 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx12_i_2_indices.begin(), ptr_arrayidx12_i_2_indices.end(), "arrayidx12.i.2", label_forbody_i11_preheader); + LoadInst* float_tmp13_i5_2 = new LoadInst(ptr_arrayidx12_i_2, "tmp13.i5.2", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp15_i6_2 = new InsertElementInst(packed_tmp7_i4_2, float_tmp13_i5_2, const_int32_28, "tmp15.i6.2", label_forbody_i11_preheader); + std::vector ptr_arrayidx20_i_2_indices; + ptr_arrayidx20_i_2_indices.push_back(const_int32_29); + ptr_arrayidx20_i_2_indices.push_back(const_int32_29); + Instruction* ptr_arrayidx20_i_2 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx20_i_2_indices.begin(), ptr_arrayidx20_i_2_indices.end(), "arrayidx20.i.2", label_forbody_i11_preheader); + LoadInst* float_tmp21_i_2 = new LoadInst(ptr_arrayidx20_i_2, "tmp21.i.2", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp23_i_2 = new InsertElementInst(packed_tmp15_i6_2, float_tmp21_i_2, const_int32_29, "tmp23.i.2", label_forbody_i11_preheader); + std::vector ptr_arrayidx28_i7_2_indices; + ptr_arrayidx28_i7_2_indices.push_back(const_int32_29); + ptr_arrayidx28_i7_2_indices.push_back(const_int32_30); + Instruction* ptr_arrayidx28_i7_2 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx28_i7_2_indices.begin(), ptr_arrayidx28_i7_2_indices.end(), "arrayidx28.i7.2", label_forbody_i11_preheader); + LoadInst* float_tmp29_i_2 = new LoadInst(ptr_arrayidx28_i7_2, "tmp29.i.2", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp31_i_2 = new InsertElementInst(packed_tmp23_i_2, float_tmp29_i_2, const_int32_30, "tmp31.i.2", label_forbody_i11_preheader); + std::vector ptr_arrayidx34_i8_2_indices; + ptr_arrayidx34_i8_2_indices.push_back(const_int32_26); + ptr_arrayidx34_i8_2_indices.push_back(const_int32_29); + Instruction* ptr_arrayidx34_i8_2 = new GetElementPtrInst(ptr_consts, ptr_arrayidx34_i8_2_indices.begin(), ptr_arrayidx34_i8_2_indices.end(), "arrayidx34.i8.2", label_forbody_i11_preheader); + new StoreInst(packed_tmp31_i_2, ptr_arrayidx34_i8_2, false, label_forbody_i11_preheader); + std::vector ptr_arraydecay_i3_3_indices; + ptr_arraydecay_i3_3_indices.push_back(const_int32_30); + ptr_arraydecay_i3_3_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay_i3_3 = new GetElementPtrInst(ptr_aconsts, ptr_arraydecay_i3_3_indices.begin(), ptr_arraydecay_i3_3_indices.end(), "arraydecay.i3.3", label_forbody_i11_preheader); + LoadInst* float_tmp5_i_3 = new LoadInst(ptr_arraydecay_i3_3, "tmp5.i.3", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp7_i4_3 = new InsertElementInst(packed_tmp31_i_2, float_tmp5_i_3, const_int32_26, "tmp7.i4.3", label_forbody_i11_preheader); + std::vector ptr_arrayidx12_i_3_indices; + ptr_arrayidx12_i_3_indices.push_back(const_int32_30); + ptr_arrayidx12_i_3_indices.push_back(const_int32_28); + Instruction* ptr_arrayidx12_i_3 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx12_i_3_indices.begin(), ptr_arrayidx12_i_3_indices.end(), "arrayidx12.i.3", label_forbody_i11_preheader); + LoadInst* float_tmp13_i5_3 = new LoadInst(ptr_arrayidx12_i_3, "tmp13.i5.3", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp15_i6_3 = new InsertElementInst(packed_tmp7_i4_3, float_tmp13_i5_3, const_int32_28, "tmp15.i6.3", label_forbody_i11_preheader); + std::vector ptr_arrayidx20_i_3_indices; + ptr_arrayidx20_i_3_indices.push_back(const_int32_30); + ptr_arrayidx20_i_3_indices.push_back(const_int32_29); + Instruction* ptr_arrayidx20_i_3 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx20_i_3_indices.begin(), ptr_arrayidx20_i_3_indices.end(), "arrayidx20.i.3", label_forbody_i11_preheader); + LoadInst* float_tmp21_i_3 = new LoadInst(ptr_arrayidx20_i_3, "tmp21.i.3", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp23_i_3 = new InsertElementInst(packed_tmp15_i6_3, float_tmp21_i_3, const_int32_29, "tmp23.i.3", label_forbody_i11_preheader); + std::vector ptr_arrayidx28_i7_3_indices; + ptr_arrayidx28_i7_3_indices.push_back(const_int32_30); + ptr_arrayidx28_i7_3_indices.push_back(const_int32_30); + Instruction* ptr_arrayidx28_i7_3 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx28_i7_3_indices.begin(), ptr_arrayidx28_i7_3_indices.end(), "arrayidx28.i7.3", label_forbody_i11_preheader); + LoadInst* float_tmp29_i_3 = new LoadInst(ptr_arrayidx28_i7_3, "tmp29.i.3", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp31_i_3 = new InsertElementInst(packed_tmp23_i_3, float_tmp29_i_3, const_int32_30, "tmp31.i.3", label_forbody_i11_preheader); + std::vector ptr_arrayidx34_i8_3_indices; + ptr_arrayidx34_i8_3_indices.push_back(const_int32_26); + ptr_arrayidx34_i8_3_indices.push_back(const_int32_30); + Instruction* ptr_arrayidx34_i8_3 = new GetElementPtrInst(ptr_consts, ptr_arrayidx34_i8_3_indices.begin(), ptr_arrayidx34_i8_3_indices.end(), "arrayidx34.i8.3", label_forbody_i11_preheader); + new StoreInst(packed_tmp31_i_3, ptr_arrayidx34_i8_3, false, label_forbody_i11_preheader); + std::vector ptr_arraydecay_i3_4_indices; + ptr_arraydecay_i3_4_indices.push_back(const_int32_33); + ptr_arraydecay_i3_4_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay_i3_4 = new GetElementPtrInst(ptr_aconsts, ptr_arraydecay_i3_4_indices.begin(), ptr_arraydecay_i3_4_indices.end(), "arraydecay.i3.4", label_forbody_i11_preheader); + LoadInst* float_tmp5_i_4 = new LoadInst(ptr_arraydecay_i3_4, "tmp5.i.4", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp7_i4_4 = new InsertElementInst(packed_tmp31_i_3, float_tmp5_i_4, const_int32_26, "tmp7.i4.4", label_forbody_i11_preheader); + std::vector ptr_arrayidx12_i_4_indices; + ptr_arrayidx12_i_4_indices.push_back(const_int32_33); + ptr_arrayidx12_i_4_indices.push_back(const_int32_28); + Instruction* ptr_arrayidx12_i_4 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx12_i_4_indices.begin(), ptr_arrayidx12_i_4_indices.end(), "arrayidx12.i.4", label_forbody_i11_preheader); + LoadInst* float_tmp13_i5_4 = new LoadInst(ptr_arrayidx12_i_4, "tmp13.i5.4", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp15_i6_4 = new InsertElementInst(packed_tmp7_i4_4, float_tmp13_i5_4, const_int32_28, "tmp15.i6.4", label_forbody_i11_preheader); + std::vector ptr_arrayidx20_i_4_indices; + ptr_arrayidx20_i_4_indices.push_back(const_int32_33); + ptr_arrayidx20_i_4_indices.push_back(const_int32_29); + Instruction* ptr_arrayidx20_i_4 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx20_i_4_indices.begin(), ptr_arrayidx20_i_4_indices.end(), "arrayidx20.i.4", label_forbody_i11_preheader); + LoadInst* float_tmp21_i_4 = new LoadInst(ptr_arrayidx20_i_4, "tmp21.i.4", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp23_i_4 = new InsertElementInst(packed_tmp15_i6_4, float_tmp21_i_4, const_int32_29, "tmp23.i.4", label_forbody_i11_preheader); + std::vector ptr_arrayidx28_i7_4_indices; + ptr_arrayidx28_i7_4_indices.push_back(const_int32_33); + ptr_arrayidx28_i7_4_indices.push_back(const_int32_30); + Instruction* ptr_arrayidx28_i7_4 = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx28_i7_4_indices.begin(), ptr_arrayidx28_i7_4_indices.end(), "arrayidx28.i7.4", label_forbody_i11_preheader); + LoadInst* float_tmp29_i_4 = new LoadInst(ptr_arrayidx28_i7_4, "tmp29.i.4", false, label_forbody_i11_preheader); + InsertElementInst* packed_tmp31_i_4 = new InsertElementInst(packed_tmp23_i_4, float_tmp29_i_4, const_int32_30, "tmp31.i.4", label_forbody_i11_preheader); + std::vector ptr_arrayidx34_i8_4_indices; + ptr_arrayidx34_i8_4_indices.push_back(const_int32_26); + ptr_arrayidx34_i8_4_indices.push_back(const_int32_33); + Instruction* ptr_arrayidx34_i8_4 = new GetElementPtrInst(ptr_consts, ptr_arrayidx34_i8_4_indices.begin(), ptr_arrayidx34_i8_4_indices.end(), "arrayidx34.i8.4", label_forbody_i11_preheader); + new StoreInst(packed_tmp31_i_4, ptr_arrayidx34_i8_4, false, label_forbody_i11_preheader); + new BranchInst(label_forbody_preheader, label_afterfor_82, int1_cmp_i, label_forbody_i11_preheader); + + // Block forbody.preheader (label_forbody_preheader) + new BranchInst(label_forbody_us, label_forbody_81, int1_cmp5_i, label_forbody_preheader); + + // Block forbody.us (label_forbody_us) + Argument* fwdref_99 = new Argument(IntegerType::get(32)); + PHINode* int32_i_012_0_us = new PHINode(IntegerType::get(32), "i.012.0.us", label_forbody_us); + int32_i_012_0_us->reserveOperandSpace(2); + int32_i_012_0_us->addIncoming(const_int32_26, label_forbody_preheader); + int32_i_012_0_us->addIncoming(fwdref_99, label_to_array_exit_us); + + std::vector ptr_arraydecay9_us_indices; + ptr_arraydecay9_us_indices.push_back(const_int32_26); + ptr_arraydecay9_us_indices.push_back(int32_i_012_0_us); + ptr_arraydecay9_us_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay9_us = new GetElementPtrInst(ptr_inputs, ptr_arraydecay9_us_indices.begin(), ptr_arraydecay9_us_indices.end(), "arraydecay9.us", label_forbody_us); + std::vector ptr_arraydecay13_us_indices; + ptr_arraydecay13_us_indices.push_back(const_int32_26); + ptr_arraydecay13_us_indices.push_back(int32_i_012_0_us); + ptr_arraydecay13_us_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay13_us = new GetElementPtrInst(ptr_results, ptr_arraydecay13_us_indices.begin(), ptr_arraydecay13_us_indices.end(), "arraydecay13.us", label_forbody_us); + std::vector void_100_params; + void_100_params.push_back(ptr_arraydecay13_us); + void_100_params.push_back(ptr_arraydecay9_us); + void_100_params.push_back(ptr_arrayidx34_i8); + CallInst* void_100 = new CallInst(func_execute_shader, void_100_params.begin(), void_100_params.end(), "", label_forbody_us); + void_100->setCallingConv(CallingConv::C); + void_100->setTailCall(false); + new BranchInst(label_forbody_i_us, label_forbody_us); + + // Block to_array.exit.us (label_to_array_exit_us) + BinaryOperator* int32_inc_us = BinaryOperator::create(Instruction::Add, int32_i_012_0_us, const_int32_28, "inc.us", label_to_array_exit_us); + ICmpInst* int1_cmp18_us = new ICmpInst(ICmpInst::ICMP_SLT, int32_inc_us, int32_count_78, "cmp18.us", label_to_array_exit_us); + new BranchInst(label_forbody_us, label_afterfor_82, int1_cmp18_us, label_to_array_exit_us); + + // Block forbody.i.us (label_forbody_i_us) + Argument* fwdref_103 = new Argument(IntegerType::get(32)); + PHINode* int32_i_01_0_i_us = new PHINode(IntegerType::get(32), "i.01.0.i.us", label_forbody_i_us); + int32_i_01_0_i_us->reserveOperandSpace(2); + int32_i_01_0_i_us->addIncoming(const_int32_26, label_forbody_us); + int32_i_01_0_i_us->addIncoming(fwdref_103, label_forbody_i_us); + + std::vector ptr_arraydecay_i_us_indices; + ptr_arraydecay_i_us_indices.push_back(int32_i_012_0_us); + ptr_arraydecay_i_us_indices.push_back(int32_i_01_0_i_us); + ptr_arraydecay_i_us_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay_i_us = new GetElementPtrInst(ptr_dests_77, ptr_arraydecay_i_us_indices.begin(), ptr_arraydecay_i_us_indices.end(), "arraydecay.i.us", label_forbody_i_us); + std::vector ptr_arrayidx6_i_us_indices; + ptr_arrayidx6_i_us_indices.push_back(const_int32_26); + ptr_arrayidx6_i_us_indices.push_back(int32_i_012_0_us); + ptr_arrayidx6_i_us_indices.push_back(int32_i_01_0_i_us); + Instruction* ptr_arrayidx6_i_us = new GetElementPtrInst(ptr_results, ptr_arrayidx6_i_us_indices.begin(), ptr_arrayidx6_i_us_indices.end(), "arrayidx6.i.us", label_forbody_i_us); + LoadInst* packed_tmp7_i_us = new LoadInst(ptr_arrayidx6_i_us, "tmp7.i.us", false, label_forbody_i_us); + ExtractElementInst* float_tmp9_i_us = new ExtractElementInst(packed_tmp7_i_us, const_int32_26, "tmp9.i.us", label_forbody_i_us); + CastInst* double_conv_i_us = new FPExtInst(float_tmp9_i_us, Type::DoubleTy, "conv.i.us", label_forbody_i_us); + ExtractElementInst* float_tmp11_i_us = new ExtractElementInst(packed_tmp7_i_us, const_int32_28, "tmp11.i.us", label_forbody_i_us); + CastInst* double_conv12_i_us = new FPExtInst(float_tmp11_i_us, Type::DoubleTy, "conv12.i.us", label_forbody_i_us); + ExtractElementInst* float_tmp14_i_us = new ExtractElementInst(packed_tmp7_i_us, const_int32_29, "tmp14.i.us", label_forbody_i_us); + CastInst* double_conv15_i_us = new FPExtInst(float_tmp14_i_us, Type::DoubleTy, "conv15.i.us", label_forbody_i_us); + ExtractElementInst* float_tmp17_i_us = new ExtractElementInst(packed_tmp7_i_us, const_int32_30, "tmp17.i.us", label_forbody_i_us); + CastInst* double_conv18_i_us = new FPExtInst(float_tmp17_i_us, Type::DoubleTy, "conv18.i.us", label_forbody_i_us); + std::vector int32_call_i_us_params; + int32_call_i_us_params.push_back(const_ptr_31); + int32_call_i_us_params.push_back(double_conv_i_us); + int32_call_i_us_params.push_back(double_conv12_i_us); + int32_call_i_us_params.push_back(double_conv15_i_us); + int32_call_i_us_params.push_back(double_conv18_i_us); + CallInst* int32_call_i_us = new CallInst(func_printf, int32_call_i_us_params.begin(), int32_call_i_us_params.end(), "call.i.us", label_forbody_i_us); + int32_call_i_us->setCallingConv(CallingConv::C); + int32_call_i_us->setTailCall(false); + new StoreInst(float_tmp9_i_us, ptr_arraydecay_i_us, false, label_forbody_i_us); + std::vector ptr_arrayidx24_i_us_indices; + ptr_arrayidx24_i_us_indices.push_back(int32_i_012_0_us); + ptr_arrayidx24_i_us_indices.push_back(int32_i_01_0_i_us); + ptr_arrayidx24_i_us_indices.push_back(const_int32_28); + Instruction* ptr_arrayidx24_i_us = new GetElementPtrInst(ptr_dests_77, ptr_arrayidx24_i_us_indices.begin(), ptr_arrayidx24_i_us_indices.end(), "arrayidx24.i.us", label_forbody_i_us); + new StoreInst(float_tmp11_i_us, ptr_arrayidx24_i_us, false, label_forbody_i_us); + std::vector ptr_arrayidx28_i_us_indices; + ptr_arrayidx28_i_us_indices.push_back(int32_i_012_0_us); + ptr_arrayidx28_i_us_indices.push_back(int32_i_01_0_i_us); + ptr_arrayidx28_i_us_indices.push_back(const_int32_29); + Instruction* ptr_arrayidx28_i_us = new GetElementPtrInst(ptr_dests_77, ptr_arrayidx28_i_us_indices.begin(), ptr_arrayidx28_i_us_indices.end(), "arrayidx28.i.us", label_forbody_i_us); + new StoreInst(float_tmp14_i_us, ptr_arrayidx28_i_us, false, label_forbody_i_us); + std::vector ptr_arrayidx32_i_us_indices; + ptr_arrayidx32_i_us_indices.push_back(int32_i_012_0_us); + ptr_arrayidx32_i_us_indices.push_back(int32_i_01_0_i_us); + ptr_arrayidx32_i_us_indices.push_back(const_int32_30); + Instruction* ptr_arrayidx32_i_us = new GetElementPtrInst(ptr_dests_77, ptr_arrayidx32_i_us_indices.begin(), ptr_arrayidx32_i_us_indices.end(), "arrayidx32.i.us", label_forbody_i_us); + new StoreInst(float_tmp17_i_us, ptr_arrayidx32_i_us, false, label_forbody_i_us); + BinaryOperator* int32_indvar_next_108 = BinaryOperator::create(Instruction::Add, int32_i_01_0_i_us, const_int32_28, "indvar.next", label_forbody_i_us); + ICmpInst* int1_exitcond_109 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_108, int32_num_attribs_79, "exitcond", label_forbody_i_us); + new BranchInst(label_to_array_exit_us, label_forbody_i_us, int1_exitcond_109, label_forbody_i_us); + + // Block forbody (label_forbody_81) + Argument* fwdref_111 = new Argument(IntegerType::get(32)); + PHINode* int32_i_012_0 = new PHINode(IntegerType::get(32), "i.012.0", label_forbody_81); + int32_i_012_0->reserveOperandSpace(2); + int32_i_012_0->addIncoming(const_int32_26, label_forbody_preheader); + int32_i_012_0->addIncoming(fwdref_111, label_forbody_81); + + std::vector ptr_arraydecay9_indices; + ptr_arraydecay9_indices.push_back(const_int32_26); + ptr_arraydecay9_indices.push_back(int32_i_012_0); + ptr_arraydecay9_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay9 = new GetElementPtrInst(ptr_inputs, ptr_arraydecay9_indices.begin(), ptr_arraydecay9_indices.end(), "arraydecay9", label_forbody_81); + std::vector ptr_arraydecay13_indices; + ptr_arraydecay13_indices.push_back(const_int32_26); + ptr_arraydecay13_indices.push_back(int32_i_012_0); + ptr_arraydecay13_indices.push_back(const_int32_26); + Instruction* ptr_arraydecay13 = new GetElementPtrInst(ptr_results, ptr_arraydecay13_indices.begin(), ptr_arraydecay13_indices.end(), "arraydecay13", label_forbody_81); + std::vector void_112_params; + void_112_params.push_back(ptr_arraydecay13); + void_112_params.push_back(ptr_arraydecay9); + void_112_params.push_back(ptr_arrayidx34_i8); + CallInst* void_112 = new CallInst(func_execute_shader, void_112_params.begin(), void_112_params.end(), "", label_forbody_81); + void_112->setCallingConv(CallingConv::C); + void_112->setTailCall(false); + BinaryOperator* int32_inc_113 = BinaryOperator::create(Instruction::Add, int32_i_012_0, const_int32_28, "inc", label_forbody_81); + ICmpInst* int1_cmp18 = new ICmpInst(ICmpInst::ICMP_SLT, int32_inc_113, int32_count_78, "cmp18", label_forbody_81); + new BranchInst(label_forbody_81, label_afterfor_82, int1_cmp18, label_forbody_81); + + // Block afterfor (label_afterfor_82) + new ReturnInst(label_afterfor_82); + + // Resolve Forward References + fwdref_86->replaceAllUsesWith(int32_i_013_0_i_ph); delete fwdref_86; + fwdref_88->replaceAllUsesWith(packed_tmp48_i); delete fwdref_88; + fwdref_87->replaceAllUsesWith(int32_inc_i); delete fwdref_87; + fwdref_85->replaceAllUsesWith(int32_inc59_i); delete fwdref_85; + fwdref_99->replaceAllUsesWith(int32_inc_us); delete fwdref_99; + fwdref_103->replaceAllUsesWith(int32_indvar_next_108); delete fwdref_103; + fwdref_111->replaceAllUsesWith(int32_inc_113); delete fwdref_111; + + } + + return mod; +} diff --git a/src/mesa/pipe/llvm/llvmtgsi.cpp b/src/mesa/pipe/llvm/llvmtgsi.cpp index 44caa59d52f..b2f6d17e966 100644 --- a/src/mesa/pipe/llvm/llvmtgsi.cpp +++ b/src/mesa/pipe/llvm/llvmtgsi.cpp @@ -257,7 +257,9 @@ translate_instruction(llvm::Module *module, out = instr->ex2(inputs[0]); } break; - case TGSI_OPCODE_LOGBASE2: + case TGSI_OPCODE_LOGBASE2: { + out = instr->lg2(inputs[0]); + } break; case TGSI_OPCODE_POWER: { out = instr->pow(inputs[0], inputs[1]);