Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Macros | 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.

Macros

#define PRINTF_FUNC
 
#define UNREACHABLE()   FatalError(__FILE__, __LINE__, "unreachable code")
 
#define FATAL(message)   FatalError(__FILE__, __LINE__, message)
 
#define Assert(expr)   ((void)((expr) ? 0 : ((void)DoAssert(__FILE__, __LINE__, #expr), 0)))
 
#define AssertPos(pos, expr)   ((void)((expr) ? 0 : ((void)DoAssertPos(pos, __FILE__, __LINE__, #expr), 0)))
 

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)
 
void DoAssert (const char *file, int line, const char *expr)
 
void DoAssertPos (SourcePos pos, const char *file, int line, const char *expr)
 
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)
 
bool VerifyDataLayoutCompatibility (const std::string &module_dl, const std::string &lib_dl)
 
void PrintWithWordBreaks (const char *buf, int indent, int columnWidth, FILE *out)
 
int TerminalWidth ()
 
bool IsStdin (const char *)
 

Macro Definition Documentation

◆ Assert

#define Assert (   expr)    ((void)((expr) ? 0 : ((void)DoAssert(__FILE__, __LINE__, #expr), 0)))

Asserts that expr parameter is not equal to zero. Otherwise the program is terminated with propper error message and with file and line number where the assertion happend.

Definition at line 128 of file util.h.

Referenced by AddBitcodeToModule(), SymbolTable::AddFunction(), Module::AddFunctionDeclaration(), Module::AddFunctionDefinition(), Module::AddGlobalVariable(), SymbolTable::AddVariable(), AllCPUs::AllCPUs(), FunctionEmitContext::applyVaryingGEP(), ArrayType::ArrayType(), AllCPUs::BackwardCompatible(), FunctionEmitContext::BroadcastValue(), CBEMangle(), CFInfo::CFInfo(), Module::CompileAndOutput(), MemberExpr::create(), Declaration::DeclareFunctions(), DefineStdlib(), Function::emitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), FixBooleanSelectPass::fixSelect(), Function::Function(), FunctionEmitContext::FunctionEmitContext(), FunctionType::FunctionType(), Function::GenerateIR(), ArrayType::GetAsConstType(), ReferenceType::GetAsConstType(), ArrayType::GetAsNonConstType(), ReferenceType::GetAsNonConstType(), AtomicType::GetAsSOAType(), ArrayType::GetAsSOAType(), AtomicType::GetAsUnboundVariabilityType(), ArrayType::GetAsUnboundVariabilityType(), ReferenceType::GetAsUnboundVariabilityType(), AtomicType::GetAsUniformType(), ArrayType::GetAsUniformType(), ReferenceType::GetAsUniformType(), ArrayType::GetAsUnsignedType(), VectorType::GetAsUnsignedType(), AtomicType::GetAsVaryingType(), ArrayType::GetAsVaryingType(), ReferenceType::GetAsVaryingType(), ReferenceType::GetBaseType(), AtomicType::GetCDeclaration(), EnumType::GetCDeclaration(), PointerType::GetCDeclaration(), ArrayType::GetCDeclaration(), ReferenceType::GetCDeclaration(), AllCPUs::GetDefaultNameFromType(), GetDirectoryAndFileName(), AtomicType::GetDIType(), EnumType::GetDIType(), PointerType::GetDIType(), ArrayType::GetDIType(), StructType::GetDIType(), ReferenceType::GetDIType(), StructType::GetElementType(), FunctionType::GetParameterDefault(), FunctionType::GetParameterName(), FunctionType::GetParameterSourcePos(), FunctionType::GetParameterType(), Function::GetReturnType(), ArrayType::GetSizedArray(), PointerType::GetString(), ArrayType::GetString(), ReferenceType::GetString(), Function::GetType(), IndexExpr::GetValue(), ReferenceType::GetVariability(), Declaration::GetVariableDeclarations(), constant_scanner::constant_iterator::isAtConstant(), ReferenceType::IsBoolType(), ReferenceType::IsConstType(), ReferenceType::IsFloatType(), isFPCSafeToPrint(), isFPIntBitCast(), ReferenceType::IsIntType(), IsStdin(), isSupportedIntegerSize(), ReferenceType::IsUnsignedType(), lAddModuleSymbols(), lAddTypeIfNew(), lAddVaryingOffsetsIfNeeded(), lAllDivBaseEqual(), lApplyLoad1(), lApplyLoad2(), lApplyLoad4(), lArrayToPointer(), lArrayVectorWidth(), lAssemble4Vector(), lAssembleResultVectors(), lCalleeArgCount(), lCheckAllOffSafety(), lCheckAndForLinear(), lCheckModuleIntrinsics(), lCoalesceGathers(), lComputeBasePtr(), lComputeSliceIndex(), lConstElementsToMask(), lConvertPointerConstant(), lConvertPtrToSliceIfNeeded(), lConvertToSlicePointer(), lCopyInTaskParameter(), lCreateDispatchFunction(), lDefineConstantIntFunc(), lEmitDispatchModule(), lEmitEnumDecls(), lEmitVaryingSelect(), lExtract248Scale(), lExtractConstOffsets(), lExtractFirstVectorElement(), lExtractFromInserts(), lExtractOffsetVector248Scale(), lExtractOrCheckGlobals(), lFinalSliceOffset(), lGenericTypeLayoutIndeterminate(), lGetAtomicLLVMType(), lGetBasePtrAndOffsets(), lGetBinaryIntrinsic(), lGetExportedParamTypes(), lGetExportedTypes(), lGetIntValue(), lGetMask(), lGetMaskStatus(), lGetMatchingBoolVectorType(), lGetOffsetScaleVec(), lGetOverloadCandidateMessage(), lGetSourcePosFromMetadata(), lGetStringArray(), lGetTypedFunc(), lGetVaryingDispatchType(), lGetVectorLLVMType(), lGSBaseOffsetsGetMoreConst(), lGSToGSBaseOffsets(), lGSToLoadStore(), lImproveMaskedLoad(), lImproveMaskedStore(), lInitDispatchModule(), lIsExactMultiple(), lIsExported(), lIsExternC(), lIsSafeToBlend(), lLLVMConstantValue(), LLVMBoolVector(), LLVMConcatVectors(), LLVMExtractVectorInts(), LLVMFlattenInsertChain(), FunctionType::LLVMFunctionType(), EnumType::LLVMType(), PointerType::LLVMType(), ArrayType::LLVMType(), StructType::LLVMType(), UndefinedStructType::LLVMType(), ReferenceType::LLVMType(), LLVMVectorIsLinear(), LLVMVectorValuesAllEqual(), lMangleStruct(), lMatchingBoolType(), lPrintFunctionDeclarations(), lReplacePseudoGS(), lReplacePseudoMaskedStore(), lStoreAssignResult(), lTypeToSuffix(), lUniformValueToVarying(), lValuesAreEqual(), lVectorIsLinearConstantInts(), lVectorShiftRightAllEqual(), lVectorValuesAllEqual(), main(), EnumType::Mangle(), PointerType::Mangle(), ArrayType::Mangle(), ReferenceType::Mangle(), FunctionType::Mangle(), FunctionEmitContext::maskedStore(), Type::MoreGeneralType(), constant_scanner::constant_iterator::operator*(), BinaryExpr::Optimize(), SymbolTable::PopScope(), PrintEscapedString(), SymbolTable::RandomSymbol(), SymbolTable::RandomType(), AtomicType::ResolveUnboundVariability(), PointerType::ResolveUnboundVariability(), ArrayType::ResolveUnboundVariability(), StructType::ResolveUnboundVariability(), ReferenceType::ResolveUnboundVariability(), FunctionType::ResolveUnboundVariability(), DebugPassFile::run(), IntrinsicsOpt::runOnBasicBlock(), InstructionSimplifyPass::simplifySelect(), ArrayType::SizeUnsizedArrays(), Target::StructOffset(), StructType::StructType(), Target::Target(), SwitchStmt::TypeCheck(), UndefinedStructType::UndefinedStructType(), VectorType::VectorType(), WalkAST(), Module::writeDevStub(), Module::writeHostStub(), Module::writeOutput(), and SymbolTable::~SymbolTable().

◆ AssertPos

#define AssertPos (   pos,
  expr 
)    ((void)((expr) ? 0 : ((void)DoAssertPos(pos, __FILE__, __LINE__, #expr), 0)))

Asserts that expr parameter is not equal to zero. Otherwise the program is terminated with propper error message and with file and line number where the assertion happend and the information about source position in the user program, which has triggered the problem.

Definition at line 142 of file util.h.

Referenced by FunctionEmitContext::AddElementOffset(), FunctionEmitContext::AddInstrumentationPoint(), FunctionEmitContext::addSwitchMaskCheck(), FunctionEmitContext::addVaryingOffsetsIfNeeded(), FunctionEmitContext::All(), FunctionEmitContext::AllocaInst(), FunctionEmitContext::Any(), FunctionEmitContext::applyVaryingGEP(), FunctionEmitContext::BinaryOperator(), FunctionEmitContext::BitCastInst(), FunctionEmitContext::BranchIfMaskAll(), FunctionEmitContext::BranchIfMaskAny(), FunctionEmitContext::BranchIfMaskNone(), FunctionEmitContext::BranchInst(), FunctionEmitContext::Break(), FunctionEmitContext::BroadcastValue(), FunctionEmitContext::CallInst(), FunctionEmitContext::CastInst(), FunctionEmitContext::CmpInst(), ConstExpr::ConstExpr(), FunctionEmitContext::Continue(), FunctionEmitContext::EmitCaseLabel(), DeclStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), SwitchStmt::EmitCode(), LabeledStmt::EmitCode(), PrintStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), FunctionEmitContext::EmitDefaultLabel(), IfStmt::emitMaskAllOn(), IfStmt::emitMaskedTrueAndFalse(), IfStmt::emitMaskMixed(), IfStmt::emitVaryingIf(), FunctionEmitContext::EndForeach(), FunctionEmitContext::EndIf(), FunctionEmitContext::EndLoop(), FunctionEmitContext::EndScope(), FunctionEmitContext::EndSwitch(), PtrDerefExpr::EstimateCost(), FunctionEmitContext::ExtractInst(), FunctionEmitContext::FPCastInst(), FunctionEmitContext::FunctionEmitContext(), FunctionEmitContext::gather(), ConstExpr::getBasicType(), FunctionSymbolExpr::getCandidateFunctions(), AddressOfExpr::GetConstant(), NullPointerExpr::GetConstant(), FunctionEmitContext::GetDIScope(), FunctionEmitContext::GetElementPtrInst(), IndexExpr::GetLValue(), MemberExpr::GetLValue(), IndexExpr::GetLValueType(), TypeCastExpr::GetLValueType(), StructMemberExpr::GetLValueType(), VectorMemberExpr::GetLValueType(), FunctionEmitContext::getMaskAtSwitchEntry(), StructMemberExpr::getStructType(), BinaryExpr::GetType(), SelectExpr::GetType(), IndexExpr::GetType(), TypeCastExpr::GetType(), PtrDerefExpr::GetType(), RefDerefExpr::GetType(), AddressOfExpr::GetType(), StructMemberExpr::GetType(), BinaryExpr::GetValue(), AssignExpr::GetValue(), SelectExpr::GetValue(), FunctionCallExpr::GetValue(), IndexExpr::GetValue(), MemberExpr::GetValue(), TypeCastExpr::GetValue(), ReferenceExpr::GetValue(), NewExpr::GetValue(), VectorMemberExpr::GetValue(), FunctionEmitContext::I1VecToBoolVec(), FunctionEmitContext::ifsInCFAllUniform(), Declarator::InitFromDeclSpecs(), Declarator::InitFromType(), InitSymbol(), FunctionEmitContext::InsertInst(), FunctionEmitContext::IntToPtrInst(), FunctionEmitContext::LaneMask(), lArrayToPointer(), FunctionEmitContext::LaunchInst(), lDoTypeConv(), lEmitBinaryArith(), lEmitBinaryPointerArith(), lEmitLogicalOp(), lEmitNegate(), lGetConstExprConstant(), lGetExprListConstant(), FunctionEmitContext::LoadInst(), lVaryingStructHasUniformMember(), FunctionEmitContext::maskedStore(), FunctionEmitContext::MemcpyInst(), FunctionEmitContext::None(), FunctionEmitContext::NotOperator(), UnaryExpr::Optimize(), BinaryExpr::Optimize(), SelectExpr::Optimize(), SymbolExpr::Optimize(), FunctionEmitContext::popCFState(), FunctionEmitContext::PtrToIntInst(), FunctionSymbolExpr::ResolveOverloads(), FunctionEmitContext::ReturnInst(), FunctionEmitContext::scatter(), FunctionEmitContext::SelectInst(), FunctionEmitContext::SExtInst(), FunctionEmitContext::ShuffleInst(), FunctionEmitContext::SmearUniform(), FunctionEmitContext::StoreInst(), FunctionEmitContext::storeUniformToSOA(), FunctionEmitContext::SwitchBoolSize(), FunctionEmitContext::SwitchInst(), FunctionEmitContext::TruncInst(), BinaryExpr::TypeCheck(), AssignExpr::TypeCheck(), FunctionCallExpr::TypeCheck(), IndexExpr::TypeCheck(), PtrDerefExpr::TypeCheck(), RefDerefExpr::TypeCheck(), AddressOfExpr::TypeCheck(), NewExpr::TypeCheck(), VectorMemberExpr::VectorMemberExpr(), FunctionEmitContext::ZExtInst(), and FunctionEmitContext::~FunctionEmitContext().

◆ FATAL

#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 116 of file util.h.

Referenced by ConstExpr::ConstExpr(), DefineStdlib(), UndefinedStructType::GetAsSOAType(), FunctionType::GetAsSOAType(), FunctionType::GetAsUnboundVariabilityType(), AtomicType::GetAsUniformType(), FunctionType::GetAsUniformType(), AtomicType::GetAsUnsignedType(), FunctionType::GetAsVaryingType(), Expr::GetBaseSymbol(), FunctionType::GetBaseType(), AtomicType::GetCDeclaration(), AtomicType::GetDIType(), EnumType::GetDIType(), PointerType::GetDIType(), VectorType::GetDIType(), CFInfo::GetForeach(), Variability::GetString(), AtomicType::GetString(), UnaryExpr::GetType(), BinaryExpr::GetType(), ExprList::GetType(), UnaryExpr::GetValue(), BinaryExpr::GetValue(), AssignExpr::GetValue(), ExprList::GetValue(), ConstExpr::GetValue(), TypeCastExpr::GetValue(), ConstExpr::GetValues(), VectorType::getVectorMemoryCount(), Globals::Globals(), InitLLVMUtil(), InitSymbol(), Target::ISAToString(), Target::ISAToTargetString(), lAssemble4Vector(), lAssembleResultVectors(), lCheckModuleIntrinsics(), lCoalesceGathers(), lEmitBinaryArith(), lEmitBinaryBitOp(), lEmitBinaryCmp(), lEmitBinaryPointerArith(), lEmitLoads(), lEmitOpAssign(), lGetAtomicLLVMType(), lGetExprListConstant(), lGetStorageClassName(), lGetVectorLLVMType(), lIsMatchWithTypeWidening(), lLLVMConstantValue(), EnumType::LLVMType(), PointerType::LLVMType(), FunctionType::LLVMType(), lMangleStructName(), lOpString(), lSignal(), lTypeConvAtomic(), AtomicType::Mangle(), Variability::MangleString(), UnaryExpr::Optimize(), TypeCastExpr::Optimize(), Declarator::Print(), ConstExpr::Print(), FunctionEmitContext::SyncInst(), Target::Target(), BinaryExpr::TypeCheck(), WalkAST(), Module::writeDispatchHeader(), Module::writeHeader(), Module::writeObjectFileOrAssembly(), and Module::writeOutput().

◆ PRINTF_FUNC

#define PRINTF_FUNC

Definition at line 63 of file util.h.

◆ UNREACHABLE

#define UNREACHABLE ( )    FatalError(__FILE__, __LINE__, "unreachable code")

Reports that unreachable location is reached. This is a kind of fatal error that causes the program to terminate.

Definition at line 110 of file util.h.

Referenced by TargetLibRegistry::getISPCTargetLib(), OSToLowerString(), and OSToString().

Function Documentation

◆ Debug()

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 366 of file util.cpp.

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

Referenced by AddBitcodeToModule(), Function::emitCode(), IfStmt::emitVaryingIf(), SelectExpr::GetValue(), lApplyLoad1(), lApplyLoad2(), lApplyLoad4(), lAssemble4Vector(), lCreateISPCSymbol(), lCreateSymbol(), lEmitLoads(), lGetConstExprConstant(), lGSToLoadStore(), LLVMVectorIsLinear(), LLVMVectorValuesAllEqual(), lSelectLoads(), BinaryExpr::Optimize(), GatherCoalescePass::runOnBasicBlock(), and TypeConvertExpr().

◆ DoAssert()

void DoAssert ( const char *  file,
int  line,
const char *  expr 
)

This function generally shouldn't be called directly, but should be used via the Assert macro, which includes the file and line number where the assertion happens. Note: avoid adding [[noreturn]] as VS2017 treats Assert macros as never returning.

Definition at line 440 of file util.cpp.

References lPrintBugText().

◆ DoAssertPos()

void DoAssertPos ( SourcePos  pos,
const char *  file,
int  line,
const char *  expr 
)

This function generally shouldn't be called directly, but should be used via the AssertPos macro, which includes the file and line number where the assertion happens. Note: avoid adding [[noreturn]] as VS2017 treats AssertPos macros as never returning.

Definition at line 446 of file util.cpp.

References Error(), and lPrintBugText().

◆ Error()

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 351 of file util.cpp.

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

Referenced by AddBitcodeToModule(), Module::AddExportedTypes(), Module::AddFunctionDeclaration(), Module::AddGlobalVariable(), SymbolTable::AddType(), SymbolTable::AddVariable(), ArchToString(), FunctionEmitContext::Break(), StructType::checkIfCanBeSOA(), checkInit(), Module::CompileAndOutput(), FunctionEmitContext::Continue(), MemberExpr::create(), FunctionEmitContext::CurrentLanesReturned(), DoAssertPos(), ArgErrors::Emit(), FunctionEmitContext::EmitCaseLabel(), DeclStmt::EmitCode(), ReturnStmt::EmitCode(), GotoStmt::EmitCode(), AssertStmt::EmitCode(), FunctionEmitContext::EmitDefaultLabel(), emitOffloadParamStruct(), Function::GenerateIR(), DeclSpecs::GetBaseType(), FunctionSymbolExpr::GetConstant(), StructMemberExpr::getElementNumber(), VectorMemberExpr::getElementNumber(), GetStructTypesNamesPositions(), Target::GetTripleString(), FunctionSymbolExpr::GetType(), StructMemberExpr::GetType(), AssignExpr::GetValue(), FunctionCallExpr::GetValue(), VectorMemberExpr::GetValue(), Declaration::GetVariableDeclarations(), Declarator::InitFromDeclSpecs(), Declarator::InitFromType(), FunctionEmitContext::initLabelBBlocks(), InitSymbol(), ISPCTargetToString(), lApplyTypeQualifiers(), lCheckExportedParameterTypes(), lCheckForConstStructMember(), lCheckForStructParameters(), lConstFoldBinaryArithOp(), lCreateBinaryOperatorCall(), lDoTypeConv(), lEmitOpAssign(), lEmitPrePostIncDec(), lGetExprListConstant(), lGetSystemISA(), FunctionEmitContext::LoadInst(), lProcessPrintArg(), lSwitchASTPreVisit(), lVaryingStructHasUniformMember(), lVectorConvert(), main(), Module::Module(), Type::MoreGeneralType(), NewExpr::NewExpr(), FunctionSymbolExpr::ResolveOverloads(), ArrayType::SizeUnsizedArrays(), FunctionEmitContext::StartForeach(), FunctionEmitContext::StoreInst(), StructType::StructType(), Target::Target(), UnaryExpr::TypeCheck(), BinaryExpr::TypeCheck(), AssignExpr::TypeCheck(), ForeachStmt::TypeCheck(), FunctionCallExpr::TypeCheck(), ForeachUniqueStmt::TypeCheck(), IndexExpr::TypeCheck(), LabeledStmt::TypeCheck(), TypeCastExpr::TypeCheck(), DeleteStmt::TypeCheck(), PtrDerefExpr::TypeCheck(), AddressOfExpr::TypeCheck(), SizeOfExpr::TypeCheck(), NewExpr::TypeCheck(), Module::writeDevStub(), Module::writeObjectFileOrAssembly(), and Module::writeOutput().

◆ FatalError()

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 434 of file util.cpp.

References lPrintBugText().

◆ GetDirectoryAndFileName()

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 516 of file util.cpp.

References Assert, Globals::currentDirectory, and g.

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

◆ IsStdin()

bool IsStdin ( const char *  )

Returns true is the filepath represents stdin, otherwise false.

Definition at line 621 of file util.cpp.

References Assert.

Referenced by Module::CompileAndOutput(), Module::CompileFile(), Module::Module(), and Module::writeDeps().

◆ MatchStrings()

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 490 of file util.cpp.

References StringEditDistance().

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

◆ PerformanceWarning()

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 397 of file util.cpp.

References Globals::emitPerfWarnings, Module::errorCount, g, SourcePos::last_line, lPrint(), m, SourcePos::name, Globals::quiet, Globals::turnOffWarnings, and Globals::warningsAsErrors.

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

◆ PrintWithWordBreaks()

void PrintWithWordBreaks ( const char *  buf,
int  indent,
int  columnWidth,
FILE *  out 
)

Print the given string to the given FILE, assuming the given output column width. Break words as needed to avoid words spilling past the last column.

Definition at line 210 of file util.cpp.

References lFindWordEnd().

Referenced by lPrint(), and usage().

◆ RoundUpPow2()

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 50 of file util.h.

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

◆ StringEditDistance()

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 455 of file util.cpp.

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

◆ TerminalWidth()

int TerminalWidth ( )

Returns the width of the terminal where the compiler is running. Finding this out may fail in a variety of reasonable situations (piping compiler output to 'less', redirecting output to a file, running the compiler under a debuffer; in this case, just return a reasonable default.

Definition at line 76 of file util.cpp.

References Globals::disableLineWrap, and g.

Referenced by lPrint(), and usage().

◆ VerifyDataLayoutCompatibility()

bool VerifyDataLayoutCompatibility ( const std::string &  module_dl,
const std::string &  lib_dl 
)

Verification routine, which ensures that DataLayout of the module being compiled is compatible with DataLayout of the library. At the moment we allow the library DataLayout to a subset of the module DataLayout (and extra floating point and vector types to be defined for module) or empty library DataLayout.

Definition at line 568 of file util.cpp.

References lGetStringArray().

Referenced by AddBitcodeToModule().

◆ Warning()

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