Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Generated by llvm2cpp - DO NOT MODIFY!
- #include <llvm/Pass.h>
- #include <llvm/ADT/SmallVector.h>
- #include <llvm/Analysis/Verifier.h>
- #include <llvm/IR/BasicBlock.h>
- #include <llvm/IR/CallingConv.h>
- #include <llvm/IR/Constants.h>
- #include <llvm/IR/DerivedTypes.h>
- #include <llvm/IR/Function.h>
- #include <llvm/IR/GlobalVariable.h>
- #include <llvm/IR/IRPrintingPasses.h>
- #include <llvm/IR/InlineAsm.h>
- #include <llvm/IR/Instructions.h>
- #include <llvm/IR/LLVMContext.h>
- #include <llvm/IR/LegacyPassManager.h>
- #include <llvm/IR/Module.h>
- #include <llvm/Support/FormattedStream.h>
- #include <llvm/Support/MathExtras.h>
- #include <algorithm>
- using namespace llvm;
- Module* makeLLVMModule();
- int main(int argc, char**argv) {
- Module* Mod = makeLLVMModule();
- verifyModule(*Mod, PrintMessageAction);
- PassManager PM;
- PM.add(createPrintModulePass(&outs()));
- PM.run(*Mod);
- return 0;
- }
- Module* makeLLVMModule() {
- // Module Construction
- Module* mod = new Module("hello.ll", getGlobalContext());
- mod->setDataLayout("");
- mod->setTargetTriple("x86_64-unknown-linux-gnu");
- // Type Definitions
- std::vector<Type*>StructTy_0_fields;
- StructTy_0_fields.push_back(IntegerType::get(mod->getContext(), 64));
- StructType *StructTy_struct_func = mod->getTypeByName("struct.func");
- if (!StructTy_struct_func) {
- StructTy_struct_func = StructType::create(mod->getContext(), "struct.func");
- }
- std::vector<Type*>StructTy_struct_func_fields;
- StructTy_struct_func_fields.push_back(IntegerType::get(mod->getContext(), 64));
- PointerType* PointerTy_2 = PointerType::get(StructTy_struct_func, 0);
- ArrayType* ArrayTy_3 = ArrayType::get(PointerTy_2, 0);
- StructTy_struct_func_fields.push_back(ArrayTy_3);
- if (StructTy_struct_func->isOpaque()) {
- StructTy_struct_func->setBody(StructTy_struct_func_fields, /*isPacked=*/false);
- }
- ArrayType* ArrayTy_1 = ArrayType::get(PointerTy_2, 2);
- StructTy_0_fields.push_back(ArrayTy_1);
- StructType *StructTy_0 = StructType::get(mod->getContext(), StructTy_0_fields, /*isPacked=*/false);
- PointerType* PointerTy_4 = PointerType::get(StructTy_0, 0);
- std::vector<Type*>StructTy_5_fields;
- StructTy_5_fields.push_back(IntegerType::get(mod->getContext(), 64));
- ArrayType* ArrayTy_6 = ArrayType::get(PointerTy_2, 1);
- StructTy_5_fields.push_back(ArrayTy_6);
- StructType *StructTy_5 = StructType::get(mod->getContext(), StructTy_5_fields, /*isPacked=*/false);
- PointerType* PointerTy_7 = PointerType::get(StructTy_5, 0);
- ArrayType* ArrayTy_8 = ArrayType::get(IntegerType::get(mod->getContext(), 8), 13);
- PointerType* PointerTy_9 = PointerType::get(ArrayTy_8, 0);
- std::vector<Type*>FuncTy_10_args;
- FunctionType* FuncTy_10 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 32),
- /*Params=*/FuncTy_10_args,
- /*isVarArg=*/false);
- PointerType* PointerTy_11 = PointerType::get(IntegerType::get(mod->getContext(), 32), 0);
- PointerType* PointerTy_12 = PointerType::get(IntegerType::get(mod->getContext(), 8), 0);
- std::vector<Type*>FuncTy_14_args;
- FuncTy_14_args.push_back(PointerTy_12);
- FunctionType* FuncTy_14 = FunctionType::get(
- /*Result=*/IntegerType::get(mod->getContext(), 32),
- /*Params=*/FuncTy_14_args,
- /*isVarArg=*/true);
- PointerType* PointerTy_13 = PointerType::get(FuncTy_14, 0);
- // Function Declarations
- Function* func_main = mod->getFunction("main");
- if (!func_main) {
- func_main = Function::Create(
- /*Type=*/FuncTy_10,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"main", mod);
- func_main->setCallingConv(CallingConv::C);
- }
- AttributeSet func_main_PAL;
- {
- SmallVector<AttributeSet, 4> Attrs;
- AttributeSet PAS;
- {
- AttrBuilder B;
- B.addAttribute(Attribute::NoUnwind);
- B.addAttribute(Attribute::UWTable);
- PAS = AttributeSet::get(mod->getContext(), ~0U, B);
- }
- Attrs.push_back(PAS);
- func_main_PAL = AttributeSet::get(mod->getContext(), Attrs);
- }
- func_main->setAttributes(func_main_PAL);
- Function* func_printf = mod->getFunction("printf");
- if (!func_printf) {
- func_printf = Function::Create(
- /*Type=*/FuncTy_14,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"printf", mod); // (external, no body)
- func_printf->setCallingConv(CallingConv::C);
- }
- AttributeSet func_printf_PAL;
- {
- SmallVector<AttributeSet, 4> Attrs;
- AttributeSet PAS;
- {
- AttrBuilder B;
- PAS = AttributeSet::get(mod->getContext(), ~0U, B);
- }
- Attrs.push_back(PAS);
- func_printf_PAL = AttributeSet::get(mod->getContext(), Attrs);
- }
- func_printf->setAttributes(func_printf_PAL);
- // Global Variable Declarations
- GlobalVariable* gvar_struct___fstack_main = new GlobalVariable(/*Module=*/*mod,
- /*Type=*/StructTy_0,
- /*isConstant=*/false,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Initializer=*/0, // has initializer, specified below
- /*Name=*/"__fstack_main");
- gvar_struct___fstack_main->setAlignment(8);
- GlobalVariable* gvar_struct___fstack_foo = new GlobalVariable(/*Module=*/*mod,
- /*Type=*/StructTy_5,
- /*isConstant=*/false,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Initializer=*/0, // has initializer, specified below
- /*Name=*/"__fstack_foo");
- gvar_struct___fstack_foo->setAlignment(8);
- GlobalVariable* gvar_struct___fstack_bar = new GlobalVariable(/*Module=*/*mod,
- /*Type=*/StructTy_5,
- /*isConstant=*/false,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Initializer=*/0, // has initializer, specified below
- /*Name=*/"__fstack_bar");
- gvar_struct___fstack_bar->setAlignment(8);
- GlobalVariable* gvar_array__str = new GlobalVariable(/*Module=*/*mod,
- /*Type=*/ArrayTy_8,
- /*isConstant=*/true,
- /*Linkage=*/GlobalValue::PrivateLinkage,
- /*Initializer=*/0, // has initializer, specified below
- /*Name=*/".str");
- gvar_array__str->setAlignment(1);
- // Constant Definitions
- std::vector<Constant*> const_struct_15_fields;
- ConstantInt* const_int64_16 = ConstantInt::get(mod->getContext(), APInt(64, StringRef("2"), 10));
- const_struct_15_fields.push_back(const_int64_16);
- std::vector<Constant*> const_array_17_elems;
- Constant* const_ptr_18 = ConstantExpr::getCast(Instruction::BitCast, gvar_struct___fstack_foo, PointerTy_2);
- const_array_17_elems.push_back(const_ptr_18);
- Constant* const_ptr_19 = ConstantExpr::getCast(Instruction::BitCast, gvar_struct___fstack_bar, PointerTy_2);
- const_array_17_elems.push_back(const_ptr_19);
- Constant* const_array_17 = ConstantArray::get(ArrayTy_1, const_array_17_elems);
- const_struct_15_fields.push_back(const_array_17);
- Constant* const_struct_15 = ConstantStruct::get(StructTy_0, const_struct_15_fields);
- ConstantAggregateZero* const_struct_20 = ConstantAggregateZero::get(StructTy_5);
- Constant *const_array_21 = ConstantDataArray::getString(mod->getContext(), "hello world\x0A", true);
- ConstantInt* const_int32_22 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("1"), 10));
- ConstantInt* const_int32_23 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("0"), 10));
- std::vector<Constant*> const_ptr_24_indices;
- const_ptr_24_indices.push_back(const_int32_23);
- const_ptr_24_indices.push_back(const_int32_23);
- Constant* const_ptr_24 = ConstantExpr::getGetElementPtr(gvar_array__str, const_ptr_24_indices);
- // Global Variable Definitions
- gvar_struct___fstack_main->setInitializer(const_struct_15);
- gvar_struct___fstack_foo->setInitializer(const_struct_20);
- gvar_struct___fstack_bar->setInitializer(const_struct_20);
- gvar_array__str->setInitializer(const_array_21);
- // Function Definitions
- // Function: main (func_main)
- {
- BasicBlock* label_25 = BasicBlock::Create(mod->getContext(), "",func_main,0);
- // Block (label_25)
- AllocaInst* ptr_26 = new AllocaInst(IntegerType::get(mod->getContext(), 32), "", label_25);
- ptr_26->setAlignment(4);
- StoreInst* void_27 = new StoreInst(const_int32_23, ptr_26, false, label_25);
- CallInst* int32_28 = CallInst::Create(func_printf, const_ptr_24, "", label_25);
- int32_28->setCallingConv(CallingConv::C);
- int32_28->setTailCall(false);
- AttributeSet int32_28_PAL;
- int32_28->setAttributes(int32_28_PAL);
- ReturnInst::Create(mod->getContext(), const_int32_23, label_25);
- }
- return mod;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement