|
Intel SPMD Program Compiler
1.3.0
|
#include <module.h>

Public Types | |
| enum | OutputType { Asm, Bitcode, Object, CXX, Header, Deps, DevStub, HostStub } |
Public Member Functions | |
| Module (const char *filename) | |
| int | CompileFile () |
| void | AddTypeDef (const std::string &name, const Type *type, SourcePos pos) |
| void | AddGlobalVariable (const std::string &name, const Type *type, Expr *initExpr, bool isConst, StorageClass storageClass, SourcePos pos) |
| void | AddFunctionDeclaration (const std::string &name, const FunctionType *ftype, StorageClass sc, bool isInline, SourcePos pos) |
| void | AddFunctionDefinition (const std::string &name, const FunctionType *ftype, Stmt *code) |
| void | AddExportedTypes (const std::vector< std::pair< const Type *, SourcePos > > &types) |
Static Public Member Functions | |
| static int | CompileAndOutput (const char *srcFile, const char *arch, const char *cpu, const char *targets, bool generatePIC, OutputType outputType, const char *outFileName, const char *headerFileName, const char *includeFileName, const char *depsFileName, const char *hostStubFileName, const char *devStubFileName) |
Public Attributes | |
| int | errorCount |
| SymbolTable * | symbolTable |
| llvm::Module * | module |
| llvm::DIBuilder * | diBuilder |
Private Member Functions | |
| bool | writeOutput (OutputType ot, const char *filename, const char *includeFileName=NULL) |
| bool | writeHeader (const char *filename) |
| bool | writeDeps (const char *filename) |
| bool | writeDevStub (const char *filename) |
| bool | writeHostStub (const char *filename) |
| bool | writeObjectFileOrAssembly (OutputType outputType, const char *filename) |
| void | execPreprocessor (const char *infilename, llvm::raw_string_ostream *ostream) const |
Static Private Member Functions | |
| static bool | writeObjectFileOrAssembly (llvm::TargetMachine *targetMachine, llvm::Module *module, OutputType outputType, const char *outFileName) |
| static bool | writeBitcode (llvm::Module *module, const char *outFileName) |
Private Attributes | |
| const char * | filename |
| AST * | ast |
| std::vector< std::pair< const Type *, SourcePos > > | exportedTypes |
| enum Module::OutputType |
After a source file has been compiled, output can be generated in a number of different formats.
| Module::Module | ( | const char * | filename | ) |
The name of the source file being compiled should be passed as the module name.
Definition at line 226 of file module.cpp.
References ast, Globals::ctx, Globals::currentDirectory, diBuilder, errorCount, filename, g, Globals::generateDebuggingSymbols, Target::GENERIC, GetDirectoryAndFileName(), Target::GetTripleString(), InitLLVMUtil(), Target::isa, ISPC_VERSION, lDeclareSizeAndPtrIntTypes(), Opt::level, module, NULL, Globals::opt, stderr, symbolTable, and Globals::target.
Adds the given type to the set of types that have their definitions included in automatically generated header files.
Definition at line 851 of file module.cpp.
References Error(), exportedTypes, and NULL.
| void Module::AddFunctionDeclaration | ( | const std::string & | name, |
| const FunctionType * | functionType, | ||
| StorageClass | storageClass, | ||
| bool | isInline, | ||
| SourcePos | pos | ||
| ) |
Add a declaration of the function defined by the given function symbol to the module.
We've got a declaration for a function to process. This function does all the work of creating the corresponding llvm::Function instance, adding the symbol for the function to the symbol table and doing various sanity checks. This function returns true upon success and false if any errors were encountered.
Definition at line 616 of file module.cpp.
References SymbolTable::AddFunction(), Assert, Globals::ctx, Type::Equal(), Error(), errorCount, SourcePos::first_line, Symbol::function, g, Globals::generateDebuggingSymbols, Target::GetISAString(), FunctionType::GetNumParameters(), FunctionType::GetParameterDefault(), FunctionType::GetParameterName(), FunctionType::GetParameterSourcePos(), FunctionType::GetParameterType(), FunctionType::GetReturnType(), FunctionType::GetReturnTypeString(), FunctionType::isExported, FunctionType::isExternC, FunctionType::isTask, Type::IsUniformType(), lCheckForStructParameters(), lCheckForVaryingParameter(), FunctionType::LLVMFunctionType(), SymbolTable::LookupFunction(), SymbolTable::LookupVariable(), lRecursiveCheckValidParamType(), m, FunctionType::Mangle(), Globals::mangleFunctionsWithTarget, module, SourcePos::name, Target::nativeVectorWidth, NULL, Symbol::pos, RoundUpPow2(), SC_EXTERN_C, SC_STATIC, symbolTable, Globals::target, Symbol::type, AtomicType::Void, and Warning().
Referenced by Declaration::DeclareFunctions().
| void Module::AddFunctionDefinition | ( | const std::string & | name, |
| const FunctionType * | ftype, | ||
| Stmt * | code | ||
| ) |
Adds the function described by the declaration information and the provided statements to the module.
Definition at line 829 of file module.cpp.
References Assert, ast, errorCount, SymbolTable::LookupFunction(), m, NULL, Symbol::pos, symbolTable, and Symbol::type.
| void Module::AddGlobalVariable | ( | const std::string & | name, |
| const Type * | type, | ||
| Expr * | initExpr, | ||
| bool | isConst, | ||
| StorageClass | storageClass, | ||
| SourcePos | pos | ||
| ) |
Add a new global variable corresponding to the given Symbol to the module. If non-NULL, initExpr gives the initiailizer expression for the global's inital value.
Definition at line 367 of file module.cpp.
References SymbolTable::AddVariable(), Assert, Symbol::constValue, Globals::ctx, diBuilder, Type::Equal(), Error(), errorCount, SourcePos::first_line, g, Expr::GetConstant(), SourcePos::GetDIFile(), Type::GetDIType(), Type::IsConstType(), Type::LLVMType(), SymbolTable::LookupFunction(), SymbolTable::LookupVariable(), module, Symbol::name, SourcePos::name, NULL, Optimize(), Symbol::pos, SC_EXTERN, SC_EXTERN_C, SC_STATIC, ArrayType::SizeUnsizedArrays(), Symbol::storageClass, Symbol::storagePtr, symbolTable, ArrayType::TotalElementCount(), Symbol::type, TypeConvertExpr(), and AtomicType::Void.
Add a named type definition to the module.
Definition at line 358 of file module.cpp.
References SymbolTable::AddType(), and symbolTable.
| static int Module::CompileAndOutput | ( | const char * | srcFile, |
| const char * | arch, | ||
| const char * | cpu, | ||
| const char * | targets, | ||
| bool | generatePIC, | ||
| OutputType | outputType, | ||
| const char * | outFileName, | ||
| const char * | headerFileName, | ||
| const char * | includeFileName, | ||
| const char * | depsFileName, | ||
| const char * | hostStubFileName, | ||
| const char * | devStubFileName | ||
| ) | [static] |
Compile the given source file, generating assembly, object file, or LLVM bitcode output, as well as (optionally) a header file with declarations of functions and types used in the ispc/application interface.
| srcFile | Pathname to ispc source file to compile |
| arch | Target architecture (e.g. "x86-64") |
| cpu | Target CPU (e.g. "core-i7") |
| targets | Target ISAs; this parameter may give a single target ISA, or may give a comma-separated list of them in case we are compiling to multiple ISAs. |
| generatePIC | Indicates whether position-independent code should be generated. |
| outputType | Type of output to generate (object files, assembly, LLVM bitcode.) |
| outFileName | Base name of output filename for object files, etc. If for example the multiple targets "sse2" and "avx" are specified in the "targets" parameter and if this parameter is "foo.o", then we'll generate multiple output files, like "foo.o", "foo_sse2.o", "foo_avx.o". |
| headerFileName | If non-NULL, emit a header file suitable for inclusion from C/C++ code with declarations of types and functions exported from the given ispc source file. |
| includeFileName | If non-NULL, gives the filename for the C++ backend to emit in an #include statement to get definitions of the builtins for the generic target. |
Referenced by main().
| int Module::CompileFile | ( | ) |
Compiles the source file passed to the Module constructor, adding its global variables and functions to both the llvm::Module and SymbolTable. Returns the number of errors during compilation.
Definition at line 299 of file module.cpp.
References ast, Globals::ctx, DefineStdlib(), errorCount, execPreprocessor(), filename, g, Globals::includeStdlib, Opt::level, module, NULL, Globals::opt, Optimize(), Globals::runCPP, stdin, symbolTable, yy_create_buffer(), yy_delete_buffer(), yy_scan_string(), yy_switch_to_buffer(), yyin, and yyparse().
| void Module::execPreprocessor | ( | const char * | infilename, |
| llvm::raw_string_ostream * | ostream | ||
| ) | const [private] |
Referenced by CompileFile().
| bool Module::writeBitcode | ( | llvm::Module * | module, |
| const char * | outFileName | ||
| ) | [static, private] |
Definition at line 951 of file module.cpp.
Referenced by writeOutput().
| bool Module::writeDeps | ( | const char * | filename | ) | [private] |
Definition at line 1275 of file module.cpp.
References registeredDependencies.
Referenced by writeOutput().
| bool Module::writeDevStub | ( | const char * | filename | ) | [private] |
Definition at line 1329 of file module.cpp.
References Assert, emitOffloadParamStruct(), Error(), Type::GetAsNonConstType(), Type::GetCDeclaration(), SymbolTable::GetMatchingFunctions(), FunctionType::GetNumParameters(), FunctionType::GetParameterName(), FunctionType::GetParameterType(), ReferenceType::GetReferenceTarget(), FunctionType::GetReturnType(), Type::GetString(), Type::IsArrayType(), Type::IsConstType(), Type::IsPointerType(), Type::IsReferenceType(), Type::IsVoidType(), lEmitEnumDecls(), lEmitStructDecls(), lEmitVectorTypedefs(), lGetExportedParamTypes(), lIsExported(), lPrintFunctionDeclarations(), m, Symbol::name, Symbol::pos, symbolTable, and Symbol::type.
Referenced by writeOutput().
| bool Module::writeHeader | ( | const char * | filename | ) | [private] |
Definition at line 1581 of file module.cpp.
References Globals::emitInstrumentation, exportedTypes, FATAL, g, SymbolTable::GetMatchingFunctions(), lEmitEnumDecls(), lEmitStructDecls(), lEmitVectorTypedefs(), lGetExportedParamTypes(), lIsExported(), lIsExternC(), lPrintFunctionDeclarations(), m, and symbolTable.
Referenced by writeOutput().
| bool Module::writeHostStub | ( | const char * | filename | ) | [private] |
Definition at line 1466 of file module.cpp.
References Assert, emitOffloadParamStruct(), FunctionType::GetCDeclaration(), SymbolTable::GetMatchingFunctions(), FunctionType::GetNumParameters(), FunctionType::GetParameterName(), FunctionType::GetParameterType(), Type::IsArrayType(), Type::IsPointerType(), lEmitEnumDecls(), lEmitStructDecls(), lEmitVectorTypedefs(), lGetExportedParamTypes(), lIsExported(), m, Symbol::name, symbolTable, and Symbol::type.
Referenced by writeOutput().
| bool Module::writeObjectFileOrAssembly | ( | OutputType | outputType, |
| const char * | filename | ||
| ) | [private] |
Definition at line 979 of file module.cpp.
References g, Target::GetTargetMachine(), module, and Globals::target.
Referenced by writeOutput().
| bool Module::writeObjectFileOrAssembly | ( | llvm::TargetMachine * | targetMachine, |
| llvm::Module * | module, | ||
| OutputType | outputType, | ||
| const char * | outFileName | ||
| ) | [static, private] |
Definition at line 987 of file module.cpp.
References g, Opt::level, Object, Globals::opt, and stderr.
| bool Module::writeOutput | ( | OutputType | ot, |
| const char * | filename, | ||
| const char * | includeFileName = NULL |
||
| ) | [private] |
Write the corresponding output type to the given file. Returns true on success, false if there has been an error. The given filename may be NULL, indicating that output should go to standard output.
Definition at line 867 of file module.cpp.
References Asm, Assert, Bitcode, CXX, Deps, DevStub, diBuilder, g, Header, HostStub, lStripUnusedDebugInfo(), module, NULL, Object, stderr, Globals::target, Target::vectorWidth, writeBitcode(), writeDeps(), writeDevStub(), writeHeader(), writeHostStub(), and writeObjectFileOrAssembly().
AST* Module::ast [private] |
Definition at line 158 of file module.h.
Referenced by AddFunctionDefinition(), CompileFile(), and Module().
| llvm::DIBuilder* Module::diBuilder |
The diBuilder manages generating debugging information
Definition at line 154 of file module.h.
Referenced by FunctionEmitContext::AddDebugPos(), AddGlobalVariable(), FunctionEmitContext::EmitFunctionParameterDebugInfo(), FunctionEmitContext::EmitVariableDebugInfo(), FunctionEmitContext::EndScope(), FunctionEmitContext::FunctionEmitContext(), SourcePos::GetDIFile(), AtomicType::GetDIType(), EnumType::GetDIType(), PointerType::GetDIType(), VectorType::GetDIType(), StructType::GetDIType(), UndefinedStructType::GetDIType(), ReferenceType::GetDIType(), FunctionType::GetDIType(), lCreateDIArray(), lDefineConstantInt(), lDefineProgramIndex(), lStripUnusedDebugInfo(), Module(), FunctionEmitContext::StartScope(), writeOutput(), and FunctionEmitContext::~FunctionEmitContext().
Total number of errors encountered during compilation.
Definition at line 144 of file module.h.
Referenced by FunctionEmitContext::AddElementOffset(), AddFunctionDeclaration(), AddFunctionDefinition(), AddGlobalVariable(), FunctionEmitContext::AllocaInst(), FunctionEmitContext::BinaryOperator(), FunctionEmitContext::BitCastInst(), FunctionEmitContext::BranchInst(), FunctionEmitContext::CallInst(), FunctionEmitContext::CastInst(), FunctionEmitContext::CmpInst(), CompileFile(), Declaration::DeclareFunctions(), DeclStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), SwitchStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), Error(), PtrDerefExpr::EstimateCost(), FunctionEmitContext::ExtractInst(), FunctionEmitContext::FPCastInst(), FunctionEmitContext::FunctionEmitContext(), ArrayType::GetAsConstType(), ReferenceType::GetAsConstType(), ArrayType::GetAsNonConstType(), ReferenceType::GetAsNonConstType(), ArrayType::GetAsSOAType(), ArrayType::GetAsUnboundVariabilityType(), ReferenceType::GetAsUnboundVariabilityType(), ArrayType::GetAsUniformType(), ReferenceType::GetAsUniformType(), ArrayType::GetAsUnsignedType(), ArrayType::GetAsVaryingType(), ReferenceType::GetAsVaryingType(), ReferenceType::GetBaseType(), AtomicType::GetCDeclaration(), EnumType::GetCDeclaration(), PointerType::GetCDeclaration(), ArrayType::GetCDeclaration(), ReferenceType::GetCDeclaration(), ExprList::GetConstant(), ConstExpr::GetConstant(), AddressOfExpr::GetConstant(), NullPointerExpr::GetConstant(), PointerType::GetDIType(), ArrayType::GetDIType(), ReferenceType::GetDIType(), FunctionEmitContext::GetElementPtrInst(), StructType::GetElementType(), IndexExpr::GetLValue(), MemberExpr::GetLValue(), StructMemberExpr::GetLValueType(), VectorMemberExpr::GetLValueType(), PointerType::GetString(), ArrayType::GetString(), ReferenceType::GetString(), PtrDerefExpr::GetType(), RefDerefExpr::GetType(), AddressOfExpr::GetType(), StructMemberExpr::GetType(), BinaryExpr::GetValue(), AssignExpr::GetValue(), FunctionCallExpr::GetValue(), IndexExpr::GetValue(), MemberExpr::GetValue(), TypeCastExpr::GetValue(), ReferenceExpr::GetValue(), NewExpr::GetValue(), VectorMemberExpr::GetValue(), ReferenceType::GetVariability(), Declaration::GetVariableDeclarations(), FunctionEmitContext::I1VecToBoolVec(), Declarator::InitFromDeclSpecs(), Declarator::InitFromType(), InitSymbol(), FunctionEmitContext::InsertInst(), FunctionEmitContext::IntToPtrInst(), ReferenceType::IsBoolType(), ReferenceType::IsConstType(), ReferenceType::IsFloatType(), ReferenceType::IsIntType(), ReferenceType::IsUnsignedType(), FunctionEmitContext::LaunchInst(), lEmitLogicalOp(), FunctionType::LLVMFunctionType(), PointerType::LLVMType(), ArrayType::LLVMType(), VectorType::LLVMType(), StructType::LLVMType(), UndefinedStructType::LLVMType(), ReferenceType::LLVMType(), FunctionEmitContext::LoadInst(), lVaryingStructHasUniformMember(), PointerType::Mangle(), ArrayType::Mangle(), ReferenceType::Mangle(), FunctionType::Mangle(), FunctionEmitContext::maskedStore(), Module(), FunctionEmitContext::NotOperator(), FunctionEmitContext::PtrToIntInst(), PointerType::ResolveUnboundVariability(), ArrayType::ResolveUnboundVariability(), ReferenceType::ResolveUnboundVariability(), FunctionType::ResolveUnboundVariability(), FunctionEmitContext::SelectInst(), FunctionEmitContext::SExtInst(), ArrayType::SizeUnsizedArrays(), FunctionEmitContext::SmearUniform(), FunctionEmitContext::StoreInst(), Target::StructOffset(), StructType::StructType(), FunctionEmitContext::TruncInst(), AssignExpr::TypeCheck(), IndexExpr::TypeCheck(), SwitchStmt::TypeCheck(), PtrDerefExpr::TypeCheck(), RefDerefExpr::TypeCheck(), AddressOfExpr::TypeCheck(), NewExpr::TypeCheck(), Warning(), and FunctionEmitContext::ZExtInst().
std::vector<std::pair<const Type *, SourcePos> > Module::exportedTypes [private] |
Definition at line 160 of file module.h.
Referenced by AddExportedTypes(), and writeHeader().
const char* Module::filename [private] |
Definition at line 157 of file module.h.
Referenced by CompileFile(), and Module().
| llvm::Module* Module::module |
llvm Module object into which globals and functions are added.
Definition at line 151 of file module.h.
Referenced by AddBitcodeToModule(), AddFunctionDeclaration(), AddGlobalVariable(), FunctionEmitContext::AddInstrumentationPoint(), FunctionEmitContext::CallInst(), CompileFile(), DeclStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), PrintStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), FunctionEmitContext::FunctionEmitContext(), FunctionEmitContext::gather(), FunctionEmitContext::GetStringPtr(), NewExpr::GetValue(), InitSymbol(), IntrinsicsOpt::IntrinsicsOpt(), FunctionEmitContext::LaunchInst(), lGetStringAsValue(), lGSBaseOffsetsGetMoreConst(), lGSToGSBaseOffsets(), lGSToLoadStore(), lImproveMaskedLoad(), lImproveMaskedStore(), lReplacePseudoGS(), lReplacePseudoMaskedStore(), FunctionEmitContext::maskedStore(), FunctionEmitContext::MemcpyInst(), Module(), IntrinsicsOpt::runOnBasicBlock(), VSelMovmskOpt::runOnBasicBlock(), GatherCoalescePass::runOnBasicBlock(), IsCompileTimeConstantPass::runOnBasicBlock(), MakeInternalFuncsStaticPass::runOnModule(), FunctionEmitContext::scatter(), SourcePos::SourcePos(), FunctionEmitContext::SyncInst(), writeObjectFileOrAssembly(), and writeOutput().
Symbol table to hold symbols visible in the current scope during compilation.
Definition at line 148 of file module.h.
Referenced by AddFunctionDeclaration(), AddFunctionDefinition(), AddGlobalVariable(), AddTypeDef(), CompileFile(), ForeachUniqueStmt::ForeachUniqueStmt(), Declaration::GetVariableDeclarations(), FunctionEmitContext::LaneMask(), Module(), BinaryExpr::Optimize(), writeDevStub(), writeHeader(), and writeHostStub().
1.7.5.1