Intel SPMD Program Compiler  1.3.0
Defines | Functions
util.h File Reference
#include "ispc.h"
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define PRINTF_FUNC
#define FATAL(message)   FatalError(__FILE__, __LINE__, message)
#define PRINTF_FUNC
#define FATAL(message)   FatalError(__FILE__, __LINE__, message)
#define PRINTF_FUNC
#define FATAL(message)   FatalError(__FILE__, __LINE__, message)
#define PRINTF_FUNC
#define FATAL(message)   FatalError(__FILE__, __LINE__, message)
#define PRINTF_FUNC
#define FATAL(message)   FatalError(__FILE__, __LINE__, message)
#define PRINTF_FUNC
#define FATAL(message)   FatalError(__FILE__, __LINE__, message)

Functions

uint32_t RoundUpPow2 (uint32_t v)
void Debug (SourcePos p, const char *format,...) PRINTF_FUNC
void Warning (SourcePos p, const char *format,...) PRINTF_FUNC
void Error (SourcePos p, const char *format,...) PRINTF_FUNC
void PerformanceWarning (SourcePos p, const char *format,...) PRINTF_FUNC
void FatalError (const char *file, int line, const char *message)
int StringEditDistance (const std::string &str1, const std::string &str2, int maxDist)
std::vector< std::string > MatchStrings (const std::string &str, const std::vector< std::string > &options)
void GetDirectoryAndFileName (const std::string &currentDir, const std::string &relativeName, std::string *directory, std::string *filename)

Detailed Description

Definition in file util.h.


Define Documentation

#define FATAL (   message)    FatalError(__FILE__, __LINE__, message)

Reports a fatal error that causes the program to terminate. This should only be used for cases where there is an internal error in the compiler.

Definition at line 113 of file util.h.

Referenced by ConstExpr::AsBool(), ConstExpr::AsDouble(), ConstExpr::AsFloat(), ConstExpr::AsInt16(), ConstExpr::AsInt32(), ConstExpr::AsInt64(), ConstExpr::AsInt8(), ConstExpr::AsUInt16(), ConstExpr::AsUInt32(), ConstExpr::AsUInt64(), ConstExpr::AsUInt8(), ConstExpr::ConstExpr(), DefineStdlib(), UndefinedStructType::GetAsSOAType(), FunctionType::GetAsSOAType(), FunctionType::GetAsUnboundVariabilityType(), FunctionType::GetAsUniformType(), AtomicType::GetAsUnsignedType(), FunctionType::GetAsVaryingType(), FunctionType::GetBaseType(), AtomicType::GetCDeclaration(), ExprList::GetConstant(), AtomicType::GetDIType(), EnumType::GetDIType(), PointerType::GetDIType(), VectorType::GetDIType(), CFInfo::GetForeach(), Target::GetISAString(), Variability::GetString(), AtomicType::GetString(), UnaryExpr::GetType(), BinaryExpr::GetType(), ExprList::GetType(), UnaryExpr::GetValue(), BinaryExpr::GetValue(), AssignExpr::GetValue(), ExprList::GetValue(), ConstExpr::GetValue(), VectorType::getVectorMemoryCount(), Globals::Globals(), InitSymbol(), lAssemble4Vector(), lAssembleResultVectors(), lCoalesceGathers(), lEmitBinaryArith(), lEmitBinaryBitOp(), lEmitBinaryCmp(), lEmitBinaryPointerArith(), lEmitLoads(), lEmitOpAssign(), lGetStorageClassName(), lIsMatchWithTypeWidening(), lLLVMConstantValue(), AtomicType::LLVMType(), EnumType::LLVMType(), PointerType::LLVMType(), VectorType::LLVMType(), FunctionType::LLVMType(), lMangleStructName(), lOpString(), lSignal(), lTypeConvAtomic(), AtomicType::Mangle(), Variability::MangleString(), UnaryExpr::Optimize(), TypeCastExpr::Optimize(), Declarator::Print(), ConstExpr::Print(), FunctionEmitContext::SyncInst(), BinaryExpr::TypeCheck(), and Module::writeHeader().

#define FATAL (   message)    FatalError(__FILE__, __LINE__, message)
#define FATAL (   message)    FatalError(__FILE__, __LINE__, message)
#define FATAL (   message)    FatalError(__FILE__, __LINE__, message)
#define FATAL (   message)    FatalError(__FILE__, __LINE__, message)
#define FATAL (   message)    FatalError(__FILE__, __LINE__, message)
#define PRINTF_FUNC
#define PRINTF_FUNC
#define PRINTF_FUNC
#define PRINTF_FUNC
#define PRINTF_FUNC

Definition at line 65 of file util.h.

#define PRINTF_FUNC

Function Documentation

void Debug ( SourcePos  p,
const char *  format,
  ... 
)

Prints a debugging message. These messages are only printed if g->debugPrint is true. In addition to a program source code position to associate with the message, a printf()-style format string is passed along with any values needed for items in the format string.

Definition at line 390 of file util.cpp.

References Globals::debugPrint, g, lPrint(), and Globals::quiet.

Referenced by IfStmt::emitVaryingIf(), ConstExpr::GetConstant(), SelectExpr::GetValue(), lApplyLoad1(), lApplyLoad2(), lApplyLoad4(), lAssemble4Vector(), lCreateISPCSymbol(), lCreateSymbol(), lEmitLoads(), lGSToLoadStore(), LLVMVectorIsLinear(), LLVMVectorValuesAllEqual(), lSelectLoads(), lStripUnusedDebugInfo(), GatherCoalescePass::runOnBasicBlock(), and TypeConvertExpr().

void Error ( SourcePos  p,
const char *  format,
  ... 
)

Prints an error message. It is assumd that compilation can not be successfully completed after an error has been issued, though the system tries to continue compiling as much as possible, in order to be able to issue any subsequent error messages. In addition to a program source code position to associate with the message, a printf()-style format string is passed along with any values needed for items in the format string.

Definition at line 377 of file util.cpp.

References Module::errorCount, g, lPrint(), m, NULL, and Globals::quiet.

Referenced by AddBitcodeToModule(), Module::AddExportedTypes(), Module::AddFunctionDeclaration(), Module::AddGlobalVariable(), SymbolTable::AddType(), SymbolTable::AddVariable(), FunctionEmitContext::Break(), StructType::checkIfCanBeSOA(), FunctionEmitContext::Continue(), MemberExpr::create(), FunctionEmitContext::CurrentLanesReturned(), DoAssertPos(), FunctionEmitContext::EmitCaseLabel(), DeclStmt::EmitCode(), ReturnStmt::EmitCode(), GotoStmt::EmitCode(), AssertStmt::EmitCode(), FunctionEmitContext::EmitDefaultLabel(), emitOffloadParamStruct(), DeclSpecs::GetBaseType(), ExprList::GetConstant(), FunctionSymbolExpr::GetConstant(), StructMemberExpr::getElementNumber(), VectorMemberExpr::getElementNumber(), GetStructTypesNamesPositions(), FunctionSymbolExpr::GetType(), StructMemberExpr::GetType(), AssignExpr::GetValue(), FunctionCallExpr::GetValue(), VectorMemberExpr::GetValue(), Declaration::GetVariableDeclarations(), Declarator::InitFromDeclSpecs(), Declarator::InitFromType(), FunctionEmitContext::initLabelBBlocks(), InitSymbol(), lApplyTypeQualifiers(), lCheckForConstStructMember(), lCheckForStructParameters(), lCheckForVaryingParameter(), lConstFoldBinArithOp(), lDoTypeConv(), lEmitOpAssign(), lEmitPrePostIncDec(), lPrintOverloadCandidates(), lProcessPrintArg(), lSwitchASTPreVisit(), lVaryingStructHasUniformMember(), lVectorConvert(), Type::MoreGeneralType(), NewExpr::NewExpr(), FunctionSymbolExpr::ResolveOverloads(), ArrayType::SizeUnsizedArrays(), FunctionEmitContext::StartForeach(), StructType::StructType(), UnaryExpr::TypeCheck(), BinaryExpr::TypeCheck(), DoStmt::TypeCheck(), ForStmt::TypeCheck(), AssignExpr::TypeCheck(), SelectExpr::TypeCheck(), ForeachStmt::TypeCheck(), FunctionCallExpr::TypeCheck(), IndexExpr::TypeCheck(), ForeachUniqueStmt::TypeCheck(), LabeledStmt::TypeCheck(), AssertStmt::TypeCheck(), DeleteStmt::TypeCheck(), TypeCastExpr::TypeCheck(), PtrDerefExpr::TypeCheck(), AddressOfExpr::TypeCheck(), SizeOfExpr::TypeCheck(), NewExpr::TypeCheck(), and Module::writeDevStub().

void FatalError ( const char *  file,
int  line,
const char *  message 
)

This function generally shouldn't be called directly, but should be used via the FATAL macro, which includes the file and line number where the error was issued.

Definition at line 447 of file util.cpp.

References lPrintBugText(), and stderr.

void GetDirectoryAndFileName ( const std::string &  currentDir,
const std::string &  relativeName,
std::string *  directory,
std::string *  filename 
)

Given the current working directory and a filename relative to that directory, this function returns the final directory that the resulting file is in and the base name of the file itself.

Definition at line 539 of file util.cpp.

References Assert, Globals::currentDirectory, g, and NULL.

Referenced by SourcePos::GetDIFile(), and Module::Module().

std::vector<std::string> MatchStrings ( const std::string &  str,
const std::vector< std::string > &  options 
)

Given a string and a set of candidate strings, returns the set of candidates that are "close" to the given string, where distance is measured by the number of single-character changes needed to transform between the two. An empty vector may be returned if none of the options is close to str.

Definition at line 511 of file util.cpp.

References StringEditDistance().

Referenced by GotoStmt::EmitCode(), and MemberExpr::getCandidateNearMatches().

void PerformanceWarning ( SourcePos  p,
const char *  format,
  ... 
)

Prints a message about a potential performance issue in the user's code. These messages are purely informative and don't affect the completion of compilation. In addition to a program source code position to associate with the message, a printf()-style format string is passed along with any values needed for items in the format string.

Definition at line 418 of file util.cpp.

References Globals::emitPerfWarnings, g, lPrint(), SourcePos::name, and Globals::quiet.

Referenced by DeclSpecs::GetBaseType(), BinaryExpr::GetValue(), lCoalescePerfInfo(), lEmitBinaryArith(), lReplacePseudoGS(), and lTypeConvAtomic().

uint32_t RoundUpPow2 ( uint32_t  v) [inline]

Rounds up the given value to the next power of two, if it isn't a power of two already.

Definition at line 51 of file util.h.

Referenced by Module::AddFunctionDeclaration(), and FunctionEmitContext::LaunchInst().

int StringEditDistance ( const std::string &  str1,
const std::string &  str2,
int  maxDist 
)

Returns the number of single-character edits needed to transform between the two strings.

Parameters:
str1First string
str2Second string
maxDistMaximum number of single-character edits allowed
Returns:
Number of single-character edits to transform from str1 to str2, or maxDist+1 if it's not psosible to do so in fewer than maxDist steps

Definition at line 474 of file util.cpp.

Referenced by SymbolTable::closestTypeMatch(), SymbolTable::ClosestVariableOrFunctionMatch(), and MatchStrings().

void Warning ( SourcePos  p,
const char *  format,
  ... 
)

Prints a warning about an issue found during compilation. Compilation can still continue after warnings; they are purely informative for the user. In addition to a program source code position to associate with the message, a printf()-style format string is passed along with any values needed for items in the format string.

Definition at line 402 of file util.cpp.

References Globals::disableWarnings, Module::errorCount, g, lPrint(), m, NULL, Globals::quiet, and Globals::warningsAsErrors.

Referenced by Module::AddFunctionDeclaration(), SymbolTable::AddVariable(), FunctionEmitContext::Break(), FunctionEmitContext::Continue(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), DeclSpecs::GetBaseType(), TypeCastExpr::GetValue(), Declarator::InitFromType(), lCheckIndicesVersusBounds(), lGSToLoadStore(), main(), BinaryExpr::Optimize(), and TypeCastExpr::TypeCheck().