Intel SPMD Program Compiler  1.3.0
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
Module Class Reference

#include <module.h>

Collaboration diagram for Module:
Collaboration graph
[legend]

List of all members.

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
SymbolTablesymbolTable
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

Detailed Description

Definition at line 50 of file module.h.


Member Enumeration Documentation

After a source file has been compiled, output can be generated in a number of different formats.

Enumerator:
Asm 
Bitcode 

Generate text assembly language output

Object 

Generate LLVM IR bitcode output

CXX 

Generate a native object file

Header 

Generate a C++ file

Deps 

Generate a C/C++ header file with declarations of 'export'ed functions, global variables, and the types used by them.

DevStub 

generate dependencies

HostStub 

generate device-side offload stubs generate host-side offload stubs

Definition at line 90 of file module.h.


Constructor & Destructor Documentation

Module::Module ( const char *  filename)

Member Function Documentation

void Module::AddExportedTypes ( const std::vector< std::pair< const Type *, SourcePos > > &  types)

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 
)
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 
)
void Module::AddTypeDef ( const std::string &  name,
const Type type,
SourcePos  pos 
)

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.

Parameters:
srcFilePathname to ispc source file to compile
archTarget architecture (e.g. "x86-64")
cpuTarget CPU (e.g. "core-i7")
targetsTarget 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.
generatePICIndicates whether position-independent code should be generated.
outputTypeType of output to generate (object files, assembly, LLVM bitcode.)
outFileNameBase 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".
headerFileNameIf 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.
includeFileNameIf 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.
Returns:
Number of errors encountered when compiling srcFile.

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]
bool Module::writeHeader ( const char *  filename) [private]
bool Module::writeHostStub ( const char *  filename) [private]
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().


Member Data Documentation

AST* Module::ast [private]

Definition at line 158 of file module.h.

Referenced by AddFunctionDefinition(), CompileFile(), and Module().

llvm::DIBuilder* Module::diBuilder

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

The documentation for this class was generated from the following files: