Add AssertPos() macro that provides rough source location in error
It can sometimes be useful to know the general place we were in the program when an assertion hit; when the position is available / applicable, this macro is now used. Issue #268.
This commit is contained in:
254
ctx.cpp
254
ctx.cpp
@@ -284,7 +284,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
|
|||||||
llvm::Constant *offFunc =
|
llvm::Constant *offFunc =
|
||||||
m->module->getOrInsertFunction(buf, LLVMTypes::VoidType,
|
m->module->getOrInsertFunction(buf, LLVMTypes::VoidType,
|
||||||
NULL);
|
NULL);
|
||||||
Assert(llvm::isa<llvm::Function>(offFunc));
|
AssertPos(currentPos, llvm::isa<llvm::Function>(offFunc));
|
||||||
llvm::BasicBlock *offBB =
|
llvm::BasicBlock *offBB =
|
||||||
llvm::BasicBlock::Create(*g->ctx, "entry",
|
llvm::BasicBlock::Create(*g->ctx, "entry",
|
||||||
(llvm::Function *)offFunc, 0);
|
(llvm::Function *)offFunc, 0);
|
||||||
@@ -302,18 +302,18 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
|
|||||||
/* If debugging is enabled, tell the debug information emission
|
/* If debugging is enabled, tell the debug information emission
|
||||||
code about this new function */
|
code about this new function */
|
||||||
diFile = funcStartPos.GetDIFile();
|
diFile = funcStartPos.GetDIFile();
|
||||||
Assert(diFile.Verify());
|
AssertPos(currentPos, diFile.Verify());
|
||||||
|
|
||||||
llvm::DIScope scope = llvm::DIScope(m->diBuilder->getCU());
|
llvm::DIScope scope = llvm::DIScope(m->diBuilder->getCU());
|
||||||
Assert(scope.Verify());
|
AssertPos(currentPos, scope.Verify());
|
||||||
|
|
||||||
const FunctionType *functionType = function->GetType();
|
const FunctionType *functionType = function->GetType();
|
||||||
llvm::DIType diSubprogramType;
|
llvm::DIType diSubprogramType;
|
||||||
if (functionType == NULL)
|
if (functionType == NULL)
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
else {
|
else {
|
||||||
diSubprogramType = functionType->GetDIType(scope);
|
diSubprogramType = functionType->GetDIType(scope);
|
||||||
Assert(diSubprogramType.Verify());
|
AssertPos(currentPos, diSubprogramType.Verify());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string mangledName = llvmFunction->getName();
|
std::string mangledName = llvmFunction->getName();
|
||||||
@@ -335,7 +335,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
|
|||||||
#endif // !LLVM_3_0
|
#endif // !LLVM_3_0
|
||||||
flags,
|
flags,
|
||||||
isOptimized, llvmFunction);
|
isOptimized, llvmFunction);
|
||||||
Assert(diSubprogram.Verify());
|
AssertPos(currentPos, diSubprogram.Verify());
|
||||||
|
|
||||||
/* And start a scope representing the initial function scope */
|
/* And start a scope representing the initial function scope */
|
||||||
StartScope();
|
StartScope();
|
||||||
@@ -344,8 +344,8 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
|
|||||||
|
|
||||||
|
|
||||||
FunctionEmitContext::~FunctionEmitContext() {
|
FunctionEmitContext::~FunctionEmitContext() {
|
||||||
Assert(controlFlowInfo.size() == 0);
|
AssertPos(currentPos, controlFlowInfo.size() == 0);
|
||||||
Assert(debugScopes.size() == (m->diBuilder ? 1 : 0));
|
AssertPos(currentPos, debugScopes.size() == (m->diBuilder ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -439,7 +439,7 @@ FunctionEmitContext::SetInternalMaskAndNot(llvm::Value *oldMask, llvm::Value *te
|
|||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::BranchIfMaskAny(llvm::BasicBlock *btrue, llvm::BasicBlock *bfalse) {
|
FunctionEmitContext::BranchIfMaskAny(llvm::BasicBlock *btrue, llvm::BasicBlock *bfalse) {
|
||||||
Assert(bblock != NULL);
|
AssertPos(currentPos, bblock != NULL);
|
||||||
llvm::Value *any = Any(GetFullMask());
|
llvm::Value *any = Any(GetFullMask());
|
||||||
BranchInst(btrue, bfalse, any);
|
BranchInst(btrue, bfalse, any);
|
||||||
// It's illegal to add any additional instructions to the basic block
|
// It's illegal to add any additional instructions to the basic block
|
||||||
@@ -450,7 +450,7 @@ FunctionEmitContext::BranchIfMaskAny(llvm::BasicBlock *btrue, llvm::BasicBlock *
|
|||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::BranchIfMaskAll(llvm::BasicBlock *btrue, llvm::BasicBlock *bfalse) {
|
FunctionEmitContext::BranchIfMaskAll(llvm::BasicBlock *btrue, llvm::BasicBlock *bfalse) {
|
||||||
Assert(bblock != NULL);
|
AssertPos(currentPos, bblock != NULL);
|
||||||
llvm::Value *all = All(GetFullMask());
|
llvm::Value *all = All(GetFullMask());
|
||||||
BranchInst(btrue, bfalse, all);
|
BranchInst(btrue, bfalse, all);
|
||||||
// It's illegal to add any additional instructions to the basic block
|
// It's illegal to add any additional instructions to the basic block
|
||||||
@@ -461,7 +461,7 @@ FunctionEmitContext::BranchIfMaskAll(llvm::BasicBlock *btrue, llvm::BasicBlock *
|
|||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::BranchIfMaskNone(llvm::BasicBlock *btrue, llvm::BasicBlock *bfalse) {
|
FunctionEmitContext::BranchIfMaskNone(llvm::BasicBlock *btrue, llvm::BasicBlock *bfalse) {
|
||||||
Assert(bblock != NULL);
|
AssertPos(currentPos, bblock != NULL);
|
||||||
// switch sense of true/false bblocks
|
// switch sense of true/false bblocks
|
||||||
BranchIfMaskAny(bfalse, btrue);
|
BranchIfMaskAny(bfalse, btrue);
|
||||||
// It's illegal to add any additional instructions to the basic block
|
// It's illegal to add any additional instructions to the basic block
|
||||||
@@ -486,7 +486,7 @@ void
|
|||||||
FunctionEmitContext::EndIf() {
|
FunctionEmitContext::EndIf() {
|
||||||
CFInfo *ci = popCFState();
|
CFInfo *ci = popCFState();
|
||||||
// Make sure we match up with a Start{Uniform,Varying}If().
|
// Make sure we match up with a Start{Uniform,Varying}If().
|
||||||
Assert(ci->IsIf());
|
AssertPos(currentPos, ci->IsIf());
|
||||||
|
|
||||||
// 'uniform' ifs don't change the mask so we only need to restore the
|
// 'uniform' ifs don't change the mask so we only need to restore the
|
||||||
// mask going into the if for 'varying' if statements
|
// mask going into the if for 'varying' if statements
|
||||||
@@ -575,7 +575,7 @@ FunctionEmitContext::StartLoop(llvm::BasicBlock *bt, llvm::BasicBlock *ct,
|
|||||||
void
|
void
|
||||||
FunctionEmitContext::EndLoop() {
|
FunctionEmitContext::EndLoop() {
|
||||||
CFInfo *ci = popCFState();
|
CFInfo *ci = popCFState();
|
||||||
Assert(ci->IsLoop());
|
AssertPos(currentPos, ci->IsLoop());
|
||||||
|
|
||||||
if (!ci->IsUniform())
|
if (!ci->IsUniform())
|
||||||
// If the loop had a 'uniform' test, then it didn't make any
|
// If the loop had a 'uniform' test, then it didn't make any
|
||||||
@@ -609,7 +609,7 @@ FunctionEmitContext::StartForeach() {
|
|||||||
void
|
void
|
||||||
FunctionEmitContext::EndForeach() {
|
FunctionEmitContext::EndForeach() {
|
||||||
CFInfo *ci = popCFState();
|
CFInfo *ci = popCFState();
|
||||||
Assert(ci->IsForeach());
|
AssertPos(currentPos, ci->IsForeach());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -654,7 +654,7 @@ FunctionEmitContext::Break(bool doCoherenceCheck) {
|
|||||||
"for/while/do loops and \"switch\" statements.");
|
"for/while/do loops and \"switch\" statements.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Assert(controlFlowInfo.size() > 0);
|
AssertPos(currentPos, controlFlowInfo.size() > 0);
|
||||||
|
|
||||||
if (bblock == NULL)
|
if (bblock == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -664,7 +664,7 @@ FunctionEmitContext::Break(bool doCoherenceCheck) {
|
|||||||
ifsInCFAllUniform(CFInfo::Switch)) {
|
ifsInCFAllUniform(CFInfo::Switch)) {
|
||||||
// We know that all program instances are executing the break, so
|
// We know that all program instances are executing the break, so
|
||||||
// just jump to the block immediately after the switch.
|
// just jump to the block immediately after the switch.
|
||||||
Assert(breakTarget != NULL);
|
AssertPos(currentPos, breakTarget != NULL);
|
||||||
BranchInst(breakTarget);
|
BranchInst(breakTarget);
|
||||||
bblock = NULL;
|
bblock = NULL;
|
||||||
return;
|
return;
|
||||||
@@ -689,7 +689,7 @@ FunctionEmitContext::Break(bool doCoherenceCheck) {
|
|||||||
// break. In these cases, we need to update the mask of the lanes
|
// break. In these cases, we need to update the mask of the lanes
|
||||||
// that have executed a 'break' statement:
|
// that have executed a 'break' statement:
|
||||||
// breakLanes = breakLanes | mask
|
// breakLanes = breakLanes | mask
|
||||||
Assert(breakLanesPtr != NULL);
|
AssertPos(currentPos, breakLanesPtr != NULL);
|
||||||
llvm::Value *mask = GetInternalMask();
|
llvm::Value *mask = GetInternalMask();
|
||||||
llvm::Value *breakMask = LoadInst(breakLanesPtr,
|
llvm::Value *breakMask = LoadInst(breakLanesPtr,
|
||||||
"break_mask");
|
"break_mask");
|
||||||
@@ -728,7 +728,7 @@ FunctionEmitContext::Continue(bool doCoherenceCheck) {
|
|||||||
"for/while/do/foreach loops.");
|
"for/while/do/foreach loops.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Assert(controlFlowInfo.size() > 0);
|
AssertPos(currentPos, controlFlowInfo.size() > 0);
|
||||||
|
|
||||||
if (ifsInCFAllUniform(CFInfo::Loop) || GetInternalMask() == LLVMMaskAllOn) {
|
if (ifsInCFAllUniform(CFInfo::Loop) || GetInternalMask() == LLVMMaskAllOn) {
|
||||||
// Similarly to 'break' statements, we can immediately jump to the
|
// Similarly to 'break' statements, we can immediately jump to the
|
||||||
@@ -744,7 +744,7 @@ FunctionEmitContext::Continue(bool doCoherenceCheck) {
|
|||||||
else {
|
else {
|
||||||
// Otherwise update the stored value of which lanes have 'continue'd.
|
// Otherwise update the stored value of which lanes have 'continue'd.
|
||||||
// continueLanes = continueLanes | mask
|
// continueLanes = continueLanes | mask
|
||||||
Assert(continueLanesPtr);
|
AssertPos(currentPos, continueLanesPtr);
|
||||||
llvm::Value *mask = GetInternalMask();
|
llvm::Value *mask = GetInternalMask();
|
||||||
llvm::Value *continueMask =
|
llvm::Value *continueMask =
|
||||||
LoadInst(continueLanesPtr, "continue_mask");
|
LoadInst(continueLanesPtr, "continue_mask");
|
||||||
@@ -772,7 +772,7 @@ FunctionEmitContext::Continue(bool doCoherenceCheck) {
|
|||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
FunctionEmitContext::ifsInCFAllUniform(int type) const {
|
FunctionEmitContext::ifsInCFAllUniform(int type) const {
|
||||||
Assert(controlFlowInfo.size() > 0);
|
AssertPos(currentPos, controlFlowInfo.size() > 0);
|
||||||
// Go backwards through controlFlowInfo, since we add new nested scopes
|
// Go backwards through controlFlowInfo, since we add new nested scopes
|
||||||
// to the back. Stop once we come to the first enclosing control flow
|
// to the back. Stop once we come to the first enclosing control flow
|
||||||
// structure of the desired type.
|
// structure of the desired type.
|
||||||
@@ -783,7 +783,7 @@ FunctionEmitContext::ifsInCFAllUniform(int type) const {
|
|||||||
return false;
|
return false;
|
||||||
--i;
|
--i;
|
||||||
}
|
}
|
||||||
Assert(i >= 0); // else we didn't find the expected control flow type!
|
AssertPos(currentPos, i >= 0); // else we didn't find the expected control flow type!
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -791,7 +791,7 @@ FunctionEmitContext::ifsInCFAllUniform(int type) const {
|
|||||||
void
|
void
|
||||||
FunctionEmitContext::jumpIfAllLoopLanesAreDone(llvm::BasicBlock *target) {
|
FunctionEmitContext::jumpIfAllLoopLanesAreDone(llvm::BasicBlock *target) {
|
||||||
llvm::Value *allDone = NULL;
|
llvm::Value *allDone = NULL;
|
||||||
Assert(continueLanesPtr != NULL);
|
AssertPos(currentPos, continueLanesPtr != NULL);
|
||||||
if (breakLanesPtr == NULL) {
|
if (breakLanesPtr == NULL) {
|
||||||
// In a foreach loop, break and return are illegal, and
|
// In a foreach loop, break and return are illegal, and
|
||||||
// breakLanesPtr is NULL. In this case, the mask is guaranteed to
|
// breakLanesPtr is NULL. In this case, the mask is guaranteed to
|
||||||
@@ -884,7 +884,7 @@ FunctionEmitContext::StartSwitch(bool cfIsUniform, llvm::BasicBlock *bbBreak) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::EndSwitch() {
|
FunctionEmitContext::EndSwitch() {
|
||||||
Assert(bblock != NULL);
|
AssertPos(currentPos, bblock != NULL);
|
||||||
|
|
||||||
CFInfo *ci = popCFState();
|
CFInfo *ci = popCFState();
|
||||||
if (ci->IsVarying() && bblock != NULL)
|
if (ci->IsVarying() && bblock != NULL)
|
||||||
@@ -903,7 +903,7 @@ FunctionEmitContext::addSwitchMaskCheck(llvm::Value *mask) {
|
|||||||
// Find the basic block for the case or default label immediately after
|
// Find the basic block for the case or default label immediately after
|
||||||
// the current one in the switch statement--that's where we want to
|
// the current one in the switch statement--that's where we want to
|
||||||
// jump if the mask is all off at this label.
|
// jump if the mask is all off at this label.
|
||||||
Assert(nextBlocks->find(bblock) != nextBlocks->end());
|
AssertPos(currentPos, nextBlocks->find(bblock) != nextBlocks->end());
|
||||||
llvm::BasicBlock *bbNext = nextBlocks->find(bblock)->second;
|
llvm::BasicBlock *bbNext = nextBlocks->find(bblock)->second;
|
||||||
|
|
||||||
// Jump to the next one of the mask is all off; otherwise jump to the
|
// Jump to the next one of the mask is all off; otherwise jump to the
|
||||||
@@ -917,11 +917,11 @@ FunctionEmitContext::addSwitchMaskCheck(llvm::Value *mask) {
|
|||||||
statement. */
|
statement. */
|
||||||
llvm::Value *
|
llvm::Value *
|
||||||
FunctionEmitContext::getMaskAtSwitchEntry() {
|
FunctionEmitContext::getMaskAtSwitchEntry() {
|
||||||
Assert(controlFlowInfo.size() > 0);
|
AssertPos(currentPos, controlFlowInfo.size() > 0);
|
||||||
int i = controlFlowInfo.size() - 1;
|
int i = controlFlowInfo.size() - 1;
|
||||||
while (i >= 0 && controlFlowInfo[i]->type != CFInfo::Switch)
|
while (i >= 0 && controlFlowInfo[i]->type != CFInfo::Switch)
|
||||||
--i;
|
--i;
|
||||||
Assert(i != -1);
|
AssertPos(currentPos, i != -1);
|
||||||
return controlFlowInfo[i]->savedMask;
|
return controlFlowInfo[i]->savedMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -936,7 +936,7 @@ FunctionEmitContext::EmitDefaultLabel(bool checkMask, SourcePos pos) {
|
|||||||
|
|
||||||
// If there's a default label in the switch, a basic block for it
|
// If there's a default label in the switch, a basic block for it
|
||||||
// should have been provided in the previous call to SwitchInst().
|
// should have been provided in the previous call to SwitchInst().
|
||||||
Assert(defaultBlock != NULL);
|
AssertPos(currentPos, defaultBlock != NULL);
|
||||||
|
|
||||||
if (bblock != NULL)
|
if (bblock != NULL)
|
||||||
// The previous case in the switch fell through, or we're in a
|
// The previous case in the switch fell through, or we're in a
|
||||||
@@ -998,13 +998,13 @@ FunctionEmitContext::EmitCaseLabel(int value, bool checkMask, SourcePos pos) {
|
|||||||
|
|
||||||
// Find the basic block for this case statement.
|
// Find the basic block for this case statement.
|
||||||
llvm::BasicBlock *bbCase = NULL;
|
llvm::BasicBlock *bbCase = NULL;
|
||||||
Assert(caseBlocks != NULL);
|
AssertPos(currentPos, caseBlocks != NULL);
|
||||||
for (int i = 0; i < (int)caseBlocks->size(); ++i)
|
for (int i = 0; i < (int)caseBlocks->size(); ++i)
|
||||||
if ((*caseBlocks)[i].first == value) {
|
if ((*caseBlocks)[i].first == value) {
|
||||||
bbCase = (*caseBlocks)[i].second;
|
bbCase = (*caseBlocks)[i].second;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Assert(bbCase != NULL);
|
AssertPos(currentPos, bbCase != NULL);
|
||||||
|
|
||||||
if (bblock != NULL)
|
if (bblock != NULL)
|
||||||
// fall through from the previous case
|
// fall through from the previous case
|
||||||
@@ -1047,7 +1047,7 @@ FunctionEmitContext::SwitchInst(llvm::Value *expr, llvm::BasicBlock *bbDefault,
|
|||||||
const std::map<llvm::BasicBlock *, llvm::BasicBlock *> &bbNext) {
|
const std::map<llvm::BasicBlock *, llvm::BasicBlock *> &bbNext) {
|
||||||
// The calling code should have called StartSwitch() before calling
|
// The calling code should have called StartSwitch() before calling
|
||||||
// SwitchInst().
|
// SwitchInst().
|
||||||
Assert(controlFlowInfo.size() &&
|
AssertPos(currentPos, controlFlowInfo.size() &&
|
||||||
controlFlowInfo.back()->IsSwitch());
|
controlFlowInfo.back()->IsSwitch());
|
||||||
|
|
||||||
switchExpr = expr;
|
switchExpr = expr;
|
||||||
@@ -1066,7 +1066,7 @@ FunctionEmitContext::SwitchInst(llvm::Value *expr, llvm::BasicBlock *bbDefault,
|
|||||||
if (expr->getType() == LLVMTypes::Int32Type)
|
if (expr->getType() == LLVMTypes::Int32Type)
|
||||||
s->addCase(LLVMInt32(bbCases[i].first), bbCases[i].second);
|
s->addCase(LLVMInt32(bbCases[i].first), bbCases[i].second);
|
||||||
else {
|
else {
|
||||||
Assert(expr->getType() == LLVMTypes::Int64Type);
|
AssertPos(currentPos, expr->getType() == LLVMTypes::Int64Type);
|
||||||
s->addCase(LLVMInt64(bbCases[i].first), bbCases[i].second);
|
s->addCase(LLVMInt64(bbCases[i].first), bbCases[i].second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1085,7 +1085,7 @@ FunctionEmitContext::SwitchInst(llvm::Value *expr, llvm::BasicBlock *bbDefault,
|
|||||||
// anyone.
|
// anyone.
|
||||||
std::map<llvm::BasicBlock *, llvm::BasicBlock *>::const_iterator iter;
|
std::map<llvm::BasicBlock *, llvm::BasicBlock *>::const_iterator iter;
|
||||||
iter = nextBlocks->find(NULL);
|
iter = nextBlocks->find(NULL);
|
||||||
Assert(iter != nextBlocks->end());
|
AssertPos(currentPos, iter != nextBlocks->end());
|
||||||
llvm::BasicBlock *bbFirst = iter->second;
|
llvm::BasicBlock *bbFirst = iter->second;
|
||||||
BranchInst(bbFirst);
|
BranchInst(bbFirst);
|
||||||
bblock = NULL;
|
bblock = NULL;
|
||||||
@@ -1282,10 +1282,10 @@ FunctionEmitContext::LaneMask(llvm::Value *v) {
|
|||||||
std::vector<Symbol *> mm;
|
std::vector<Symbol *> mm;
|
||||||
m->symbolTable->LookupFunction("__movmsk", &mm);
|
m->symbolTable->LookupFunction("__movmsk", &mm);
|
||||||
if (g->target.maskBitCount == 1)
|
if (g->target.maskBitCount == 1)
|
||||||
Assert(mm.size() == 1);
|
AssertPos(currentPos, mm.size() == 1);
|
||||||
else
|
else
|
||||||
// There should be one with signed int signature, one unsigned int.
|
// There should be one with signed int signature, one unsigned int.
|
||||||
Assert(mm.size() == 2);
|
AssertPos(currentPos, mm.size() == 2);
|
||||||
// We can actually call either one, since both are i32s as far as
|
// We can actually call either one, since both are i32s as far as
|
||||||
// LLVM's type system is concerned...
|
// LLVM's type system is concerned...
|
||||||
llvm::Function *fmm = mm[0]->function;
|
llvm::Function *fmm = mm[0]->function;
|
||||||
@@ -1337,7 +1337,7 @@ FunctionEmitContext::CreateBasicBlock(const char *name) {
|
|||||||
llvm::Value *
|
llvm::Value *
|
||||||
FunctionEmitContext::I1VecToBoolVec(llvm::Value *b) {
|
FunctionEmitContext::I1VecToBoolVec(llvm::Value *b) {
|
||||||
if (b == NULL) {
|
if (b == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1385,7 +1385,7 @@ lGetStringAsValue(llvm::BasicBlock *bblock, const char *s) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::AddInstrumentationPoint(const char *note) {
|
FunctionEmitContext::AddInstrumentationPoint(const char *note) {
|
||||||
Assert(note != NULL);
|
AssertPos(currentPos, note != NULL);
|
||||||
if (!g->emitInstrumentation)
|
if (!g->emitInstrumentation)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1445,7 +1445,7 @@ FunctionEmitContext::StartScope() {
|
|||||||
m->diBuilder->createLexicalBlock(parentScope, diFile,
|
m->diBuilder->createLexicalBlock(parentScope, diFile,
|
||||||
currentPos.first_line,
|
currentPos.first_line,
|
||||||
currentPos.first_column);
|
currentPos.first_column);
|
||||||
Assert(lexicalBlock.Verify());
|
AssertPos(currentPos, lexicalBlock.Verify());
|
||||||
debugScopes.push_back(lexicalBlock);
|
debugScopes.push_back(lexicalBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1454,7 +1454,7 @@ FunctionEmitContext::StartScope() {
|
|||||||
void
|
void
|
||||||
FunctionEmitContext::EndScope() {
|
FunctionEmitContext::EndScope() {
|
||||||
if (m->diBuilder != NULL) {
|
if (m->diBuilder != NULL) {
|
||||||
Assert(debugScopes.size() > 0);
|
AssertPos(currentPos, debugScopes.size() > 0);
|
||||||
debugScopes.pop_back();
|
debugScopes.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1462,7 +1462,7 @@ FunctionEmitContext::EndScope() {
|
|||||||
|
|
||||||
llvm::DIScope
|
llvm::DIScope
|
||||||
FunctionEmitContext::GetDIScope() const {
|
FunctionEmitContext::GetDIScope() const {
|
||||||
Assert(debugScopes.size() > 0);
|
AssertPos(currentPos, debugScopes.size() > 0);
|
||||||
return debugScopes.back();
|
return debugScopes.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1474,7 +1474,7 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
|
|||||||
|
|
||||||
llvm::DIScope scope = GetDIScope();
|
llvm::DIScope scope = GetDIScope();
|
||||||
llvm::DIType diType = sym->type->GetDIType(scope);
|
llvm::DIType diType = sym->type->GetDIType(scope);
|
||||||
Assert(diType.Verify());
|
AssertPos(currentPos, diType.Verify());
|
||||||
llvm::DIVariable var =
|
llvm::DIVariable var =
|
||||||
m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_auto_variable,
|
m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_auto_variable,
|
||||||
scope,
|
scope,
|
||||||
@@ -1483,7 +1483,7 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
|
|||||||
sym->pos.first_line,
|
sym->pos.first_line,
|
||||||
diType,
|
diType,
|
||||||
true /* preserve through opts */);
|
true /* preserve through opts */);
|
||||||
Assert(var.Verify());
|
AssertPos(currentPos, var.Verify());
|
||||||
llvm::Instruction *declareInst =
|
llvm::Instruction *declareInst =
|
||||||
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
|
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
|
||||||
AddDebugPos(declareInst, &sym->pos, &scope);
|
AddDebugPos(declareInst, &sym->pos, &scope);
|
||||||
@@ -1497,7 +1497,7 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) {
|
|||||||
|
|
||||||
llvm::DIScope scope = diSubprogram;
|
llvm::DIScope scope = diSubprogram;
|
||||||
llvm::DIType diType = sym->type->GetDIType(scope);
|
llvm::DIType diType = sym->type->GetDIType(scope);
|
||||||
Assert(diType.Verify());
|
AssertPos(currentPos, diType.Verify());
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
llvm::DIVariable var =
|
llvm::DIVariable var =
|
||||||
@@ -1510,7 +1510,7 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) {
|
|||||||
true /* preserve through opts */,
|
true /* preserve through opts */,
|
||||||
flags,
|
flags,
|
||||||
argNum+1);
|
argNum+1);
|
||||||
Assert(var.Verify());
|
AssertPos(currentPos, var.Verify());
|
||||||
llvm::Instruction *declareInst =
|
llvm::Instruction *declareInst =
|
||||||
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
|
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
|
||||||
AddDebugPos(declareInst, &sym->pos, &scope);
|
AddDebugPos(declareInst, &sym->pos, &scope);
|
||||||
@@ -1545,11 +1545,11 @@ FunctionEmitContext::BinaryOperator(llvm::Instruction::BinaryOps inst,
|
|||||||
llvm::Value *v0, llvm::Value *v1,
|
llvm::Value *v0, llvm::Value *v1,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (v0 == NULL || v1 == NULL) {
|
if (v0 == NULL || v1 == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert(v0->getType() == v1->getType());
|
AssertPos(currentPos, v0->getType() == v1->getType());
|
||||||
llvm::Type *type = v0->getType();
|
llvm::Type *type = v0->getType();
|
||||||
int arraySize = lArrayVectorWidth(type);
|
int arraySize = lArrayVectorWidth(type);
|
||||||
if (arraySize == 0) {
|
if (arraySize == 0) {
|
||||||
@@ -1577,7 +1577,7 @@ FunctionEmitContext::BinaryOperator(llvm::Instruction::BinaryOps inst,
|
|||||||
llvm::Value *
|
llvm::Value *
|
||||||
FunctionEmitContext::NotOperator(llvm::Value *v, const char *name) {
|
FunctionEmitContext::NotOperator(llvm::Value *v, const char *name) {
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1632,11 +1632,11 @@ FunctionEmitContext::CmpInst(llvm::Instruction::OtherOps inst,
|
|||||||
llvm::Value *v0, llvm::Value *v1,
|
llvm::Value *v0, llvm::Value *v1,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (v0 == NULL || v1 == NULL) {
|
if (v0 == NULL || v1 == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert(v0->getType() == v1->getType());
|
AssertPos(currentPos, v0->getType() == v1->getType());
|
||||||
llvm::Type *type = v0->getType();
|
llvm::Type *type = v0->getType();
|
||||||
int arraySize = lArrayVectorWidth(type);
|
int arraySize = lArrayVectorWidth(type);
|
||||||
if (arraySize == 0) {
|
if (arraySize == 0) {
|
||||||
@@ -1663,7 +1663,7 @@ FunctionEmitContext::CmpInst(llvm::Instruction::OtherOps inst,
|
|||||||
llvm::Value *
|
llvm::Value *
|
||||||
FunctionEmitContext::SmearUniform(llvm::Value *value, const char *name) {
|
FunctionEmitContext::SmearUniform(llvm::Value *value, const char *name) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1697,7 +1697,7 @@ llvm::Value *
|
|||||||
FunctionEmitContext::BitCastInst(llvm::Value *value, llvm::Type *type,
|
FunctionEmitContext::BitCastInst(llvm::Value *value, llvm::Type *type,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1713,7 +1713,7 @@ FunctionEmitContext::BitCastInst(llvm::Value *value, llvm::Type *type,
|
|||||||
llvm::Value *
|
llvm::Value *
|
||||||
FunctionEmitContext::PtrToIntInst(llvm::Value *value, const char *name) {
|
FunctionEmitContext::PtrToIntInst(llvm::Value *value, const char *name) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1734,7 +1734,7 @@ llvm::Value *
|
|||||||
FunctionEmitContext::PtrToIntInst(llvm::Value *value, llvm::Type *toType,
|
FunctionEmitContext::PtrToIntInst(llvm::Value *value, llvm::Type *toType,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1750,7 +1750,7 @@ FunctionEmitContext::PtrToIntInst(llvm::Value *value, llvm::Type *toType,
|
|||||||
else if (fromType->getScalarSizeInBits() > toType->getScalarSizeInBits())
|
else if (fromType->getScalarSizeInBits() > toType->getScalarSizeInBits())
|
||||||
return TruncInst(value, toType, name);
|
return TruncInst(value, toType, name);
|
||||||
else {
|
else {
|
||||||
Assert(fromType->getScalarSizeInBits() <
|
AssertPos(currentPos, fromType->getScalarSizeInBits() <
|
||||||
toType->getScalarSizeInBits());
|
toType->getScalarSizeInBits());
|
||||||
return ZExtInst(value, toType, name);
|
return ZExtInst(value, toType, name);
|
||||||
}
|
}
|
||||||
@@ -1766,7 +1766,7 @@ llvm::Value *
|
|||||||
FunctionEmitContext::IntToPtrInst(llvm::Value *value, llvm::Type *toType,
|
FunctionEmitContext::IntToPtrInst(llvm::Value *value, llvm::Type *toType,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1782,7 +1782,7 @@ FunctionEmitContext::IntToPtrInst(llvm::Value *value, llvm::Type *toType,
|
|||||||
else if (fromType->getScalarSizeInBits() > toType->getScalarSizeInBits())
|
else if (fromType->getScalarSizeInBits() > toType->getScalarSizeInBits())
|
||||||
return TruncInst(value, toType, name);
|
return TruncInst(value, toType, name);
|
||||||
else {
|
else {
|
||||||
Assert(fromType->getScalarSizeInBits() <
|
AssertPos(currentPos, fromType->getScalarSizeInBits() <
|
||||||
toType->getScalarSizeInBits());
|
toType->getScalarSizeInBits());
|
||||||
return ZExtInst(value, toType, name);
|
return ZExtInst(value, toType, name);
|
||||||
}
|
}
|
||||||
@@ -1799,7 +1799,7 @@ llvm::Instruction *
|
|||||||
FunctionEmitContext::TruncInst(llvm::Value *value, llvm::Type *type,
|
FunctionEmitContext::TruncInst(llvm::Value *value, llvm::Type *type,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1818,7 +1818,7 @@ llvm::Instruction *
|
|||||||
FunctionEmitContext::CastInst(llvm::Instruction::CastOps op, llvm::Value *value,
|
FunctionEmitContext::CastInst(llvm::Instruction::CastOps op, llvm::Value *value,
|
||||||
llvm::Type *type, const char *name) {
|
llvm::Type *type, const char *name) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1838,7 +1838,7 @@ llvm::Instruction *
|
|||||||
FunctionEmitContext::FPCastInst(llvm::Value *value, llvm::Type *type,
|
FunctionEmitContext::FPCastInst(llvm::Value *value, llvm::Type *type,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1857,7 +1857,7 @@ llvm::Instruction *
|
|||||||
FunctionEmitContext::SExtInst(llvm::Value *value, llvm::Type *type,
|
FunctionEmitContext::SExtInst(llvm::Value *value, llvm::Type *type,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1876,7 +1876,7 @@ llvm::Instruction *
|
|||||||
FunctionEmitContext::ZExtInst(llvm::Value *value, llvm::Type *type,
|
FunctionEmitContext::ZExtInst(llvm::Value *value, llvm::Type *type,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1953,7 +1953,7 @@ FunctionEmitContext::applyVaryingGEP(llvm::Value *basePtr, llvm::Value *index,
|
|||||||
// index must be varying for this method to be called.
|
// index must be varying for this method to be called.
|
||||||
bool baseIsUniform =
|
bool baseIsUniform =
|
||||||
(llvm::isa<llvm::PointerType>(basePtr->getType()));
|
(llvm::isa<llvm::PointerType>(basePtr->getType()));
|
||||||
Assert(baseIsUniform == false || indexIsVarying == true);
|
AssertPos(currentPos, baseIsUniform == false || indexIsVarying == true);
|
||||||
llvm::Value *varyingPtr = baseIsUniform ? SmearUniform(basePtr) : basePtr;
|
llvm::Value *varyingPtr = baseIsUniform ? SmearUniform(basePtr) : basePtr;
|
||||||
|
|
||||||
// newPtr = ptr + offset
|
// newPtr = ptr + offset
|
||||||
@@ -2057,7 +2057,7 @@ llvm::Value *
|
|||||||
FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index,
|
FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index,
|
||||||
const Type *ptrRefType, const char *name) {
|
const Type *ptrRefType, const char *name) {
|
||||||
if (basePtr == NULL || index == NULL) {
|
if (basePtr == NULL || index == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2067,11 +2067,11 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index,
|
|||||||
ptrType = PointerType::GetUniform(ptrRefType->GetReferenceTarget());
|
ptrType = PointerType::GetUniform(ptrRefType->GetReferenceTarget());
|
||||||
else {
|
else {
|
||||||
ptrType = CastType<PointerType>(ptrRefType);
|
ptrType = CastType<PointerType>(ptrRefType);
|
||||||
Assert(ptrType != NULL);
|
AssertPos(currentPos, ptrType != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptrType->IsSlice()) {
|
if (ptrType->IsSlice()) {
|
||||||
Assert(llvm::isa<llvm::StructType>(basePtr->getType()));
|
AssertPos(currentPos, llvm::isa<llvm::StructType>(basePtr->getType()));
|
||||||
|
|
||||||
llvm::Value *ptrSliceOffset = ExtractInst(basePtr, 1);
|
llvm::Value *ptrSliceOffset = ExtractInst(basePtr, 1);
|
||||||
if (ptrType->IsFrozenSlice() == false) {
|
if (ptrType->IsFrozenSlice() == false) {
|
||||||
@@ -2099,9 +2099,9 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index,
|
|||||||
// Double-check consistency between the given pointer type and its LLVM
|
// Double-check consistency between the given pointer type and its LLVM
|
||||||
// type.
|
// type.
|
||||||
if (ptrType->IsUniformType())
|
if (ptrType->IsUniformType())
|
||||||
Assert(llvm::isa<llvm::PointerType>(basePtr->getType()));
|
AssertPos(currentPos, llvm::isa<llvm::PointerType>(basePtr->getType()));
|
||||||
else if (ptrType->IsVaryingType())
|
else if (ptrType->IsVaryingType())
|
||||||
Assert(llvm::isa<llvm::VectorType>(basePtr->getType()));
|
AssertPos(currentPos, llvm::isa<llvm::VectorType>(basePtr->getType()));
|
||||||
|
|
||||||
bool indexIsVaryingType =
|
bool indexIsVaryingType =
|
||||||
llvm::isa<llvm::VectorType>(index->getType());
|
llvm::isa<llvm::VectorType>(index->getType());
|
||||||
@@ -2127,7 +2127,7 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index0
|
|||||||
llvm::Value *index1, const Type *ptrRefType,
|
llvm::Value *index1, const Type *ptrRefType,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (basePtr == NULL || index0 == NULL || index1 == NULL) {
|
if (basePtr == NULL || index0 == NULL || index1 == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2137,14 +2137,14 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index0
|
|||||||
ptrType = PointerType::GetUniform(ptrRefType->GetReferenceTarget());
|
ptrType = PointerType::GetUniform(ptrRefType->GetReferenceTarget());
|
||||||
else {
|
else {
|
||||||
ptrType = CastType<PointerType>(ptrRefType);
|
ptrType = CastType<PointerType>(ptrRefType);
|
||||||
Assert(ptrType != NULL);
|
AssertPos(currentPos, ptrType != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptrType->IsSlice()) {
|
if (ptrType->IsSlice()) {
|
||||||
// Similar to the 1D GEP implementation above, for non-frozen slice
|
// Similar to the 1D GEP implementation above, for non-frozen slice
|
||||||
// pointers we do the two-step indexing calculation and then pass
|
// pointers we do the two-step indexing calculation and then pass
|
||||||
// the new major index on to a recursive GEP call.
|
// the new major index on to a recursive GEP call.
|
||||||
Assert(llvm::isa<llvm::StructType>(basePtr->getType()));
|
AssertPos(currentPos, llvm::isa<llvm::StructType>(basePtr->getType()));
|
||||||
llvm::Value *ptrSliceOffset = ExtractInst(basePtr, 1);
|
llvm::Value *ptrSliceOffset = ExtractInst(basePtr, 1);
|
||||||
if (ptrType->IsFrozenSlice() == false) {
|
if (ptrType->IsFrozenSlice() == false) {
|
||||||
llvm::Value *newSliceOffset;
|
llvm::Value *newSliceOffset;
|
||||||
@@ -2185,7 +2185,7 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index0
|
|||||||
// out the type of ptr0.
|
// out the type of ptr0.
|
||||||
const Type *baseType = ptrType->GetBaseType();
|
const Type *baseType = ptrType->GetBaseType();
|
||||||
const SequentialType *st = CastType<SequentialType>(baseType);
|
const SequentialType *st = CastType<SequentialType>(baseType);
|
||||||
Assert(st != NULL);
|
AssertPos(currentPos, st != NULL);
|
||||||
|
|
||||||
bool ptr0IsUniform =
|
bool ptr0IsUniform =
|
||||||
llvm::isa<llvm::PointerType>(ptr0->getType());
|
llvm::isa<llvm::PointerType>(ptr0->getType());
|
||||||
@@ -2204,7 +2204,7 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
|
|||||||
const Type *ptrRefType, const char *name,
|
const Type *ptrRefType, const char *name,
|
||||||
const PointerType **resultPtrType) {
|
const PointerType **resultPtrType) {
|
||||||
if (resultPtrType != NULL)
|
if (resultPtrType != NULL)
|
||||||
Assert(ptrRefType != NULL);
|
AssertPos(currentPos, ptrRefType != NULL);
|
||||||
|
|
||||||
llvm::PointerType *llvmPtrType =
|
llvm::PointerType *llvmPtrType =
|
||||||
llvm::dyn_cast<llvm::PointerType>(fullBasePtr->getType());
|
llvm::dyn_cast<llvm::PointerType>(fullBasePtr->getType());
|
||||||
@@ -2212,7 +2212,7 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
|
|||||||
llvm::StructType *llvmStructType =
|
llvm::StructType *llvmStructType =
|
||||||
llvm::dyn_cast<llvm::StructType>(llvmPtrType->getElementType());
|
llvm::dyn_cast<llvm::StructType>(llvmPtrType->getElementType());
|
||||||
if (llvmStructType != NULL && llvmStructType->isSized() == false) {
|
if (llvmStructType != NULL && llvmStructType->isSized() == false) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2226,7 +2226,7 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
|
|||||||
ptrType = PointerType::GetUniform(ptrRefType->GetReferenceTarget());
|
ptrType = PointerType::GetUniform(ptrRefType->GetReferenceTarget());
|
||||||
else
|
else
|
||||||
ptrType = CastType<PointerType>(ptrRefType);
|
ptrType = CastType<PointerType>(ptrRefType);
|
||||||
Assert(ptrType != NULL);
|
AssertPos(currentPos, ptrType != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similarly, we have to see if the pointer type is a struct to see if
|
// Similarly, we have to see if the pointer type is a struct to see if
|
||||||
@@ -2237,7 +2237,7 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
|
|||||||
llvm::isa<llvm::StructType>(fullBasePtr->getType());
|
llvm::isa<llvm::StructType>(fullBasePtr->getType());
|
||||||
const PointerType *rpt;
|
const PointerType *rpt;
|
||||||
if (baseIsSlicePtr) {
|
if (baseIsSlicePtr) {
|
||||||
Assert(ptrType != NULL);
|
AssertPos(currentPos, ptrType != NULL);
|
||||||
// Update basePtr to just be the part that actually points to the
|
// Update basePtr to just be the part that actually points to the
|
||||||
// start of an soa<> struct for now; the element offset computation
|
// start of an soa<> struct for now; the element offset computation
|
||||||
// doesn't change the slice offset, so we'll incorporate that into
|
// doesn't change the slice offset, so we'll incorporate that into
|
||||||
@@ -2250,10 +2250,10 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
|
|||||||
// Return the pointer type of the result of this call, for callers that
|
// Return the pointer type of the result of this call, for callers that
|
||||||
// want it.
|
// want it.
|
||||||
if (resultPtrType != NULL) {
|
if (resultPtrType != NULL) {
|
||||||
Assert(ptrType != NULL);
|
AssertPos(currentPos, ptrType != NULL);
|
||||||
const CollectionType *ct =
|
const CollectionType *ct =
|
||||||
CastType<CollectionType>(ptrType->GetBaseType());
|
CastType<CollectionType>(ptrType->GetBaseType());
|
||||||
Assert(ct != NULL);
|
AssertPos(currentPos, ct != NULL);
|
||||||
*resultPtrType = new PointerType(ct->GetElementType(elementNum),
|
*resultPtrType = new PointerType(ct->GetElementType(elementNum),
|
||||||
ptrType->GetVariability(),
|
ptrType->GetVariability(),
|
||||||
ptrType->IsConstType(),
|
ptrType->IsConstType(),
|
||||||
@@ -2285,7 +2285,7 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
|
|||||||
// type of the vector.
|
// type of the vector.
|
||||||
const SequentialType *st =
|
const SequentialType *st =
|
||||||
CastType<SequentialType>(ptrType->GetBaseType());
|
CastType<SequentialType>(ptrType->GetBaseType());
|
||||||
Assert(st != NULL);
|
AssertPos(currentPos, st != NULL);
|
||||||
llvm::Value *size =
|
llvm::Value *size =
|
||||||
g->target.SizeOf(st->GetElementType()->LLVMType(g->ctx), bblock);
|
g->target.SizeOf(st->GetElementType()->LLVMType(g->ctx), bblock);
|
||||||
llvm::Value *scale = (g->target.is32Bit || g->opt.force32BitAddressing) ?
|
llvm::Value *scale = (g->target.is32Bit || g->opt.force32BitAddressing) ?
|
||||||
@@ -2317,13 +2317,13 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
|
|||||||
llvm::Value *
|
llvm::Value *
|
||||||
FunctionEmitContext::LoadInst(llvm::Value *ptr, const char *name) {
|
FunctionEmitContext::LoadInst(llvm::Value *ptr, const char *name) {
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::PointerType *pt =
|
llvm::PointerType *pt =
|
||||||
llvm::dyn_cast<llvm::PointerType>(ptr->getType());
|
llvm::dyn_cast<llvm::PointerType>(ptr->getType());
|
||||||
Assert(pt != NULL);
|
AssertPos(currentPos, pt != NULL);
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = LLVMGetName(ptr, "_load");
|
name = LLVMGetName(ptr, "_load");
|
||||||
@@ -2419,11 +2419,11 @@ llvm::Value *
|
|||||||
FunctionEmitContext::LoadInst(llvm::Value *ptr, llvm::Value *mask,
|
FunctionEmitContext::LoadInst(llvm::Value *ptr, llvm::Value *mask,
|
||||||
const Type *ptrRefType, const char *name) {
|
const Type *ptrRefType, const char *name) {
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert(ptrRefType != NULL && mask != NULL);
|
AssertPos(currentPos, ptrRefType != NULL && mask != NULL);
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = LLVMGetName(ptr, "_load");
|
name = LLVMGetName(ptr, "_load");
|
||||||
@@ -2433,7 +2433,7 @@ FunctionEmitContext::LoadInst(llvm::Value *ptr, llvm::Value *mask,
|
|||||||
ptrType = PointerType::GetUniform(ptrRefType->GetReferenceTarget());
|
ptrType = PointerType::GetUniform(ptrRefType->GetReferenceTarget());
|
||||||
else {
|
else {
|
||||||
ptrType = CastType<PointerType>(ptrRefType);
|
ptrType = CastType<PointerType>(ptrRefType);
|
||||||
Assert(ptrType != NULL);
|
AssertPos(currentPos, ptrType != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptrType->IsUniformType()) {
|
if (ptrType->IsUniformType()) {
|
||||||
@@ -2476,7 +2476,7 @@ llvm::Value *
|
|||||||
FunctionEmitContext::gather(llvm::Value *ptr, const PointerType *ptrType,
|
FunctionEmitContext::gather(llvm::Value *ptr, const PointerType *ptrType,
|
||||||
llvm::Value *mask, const char *name) {
|
llvm::Value *mask, const char *name) {
|
||||||
// We should have a varying pointer if we get here...
|
// We should have a varying pointer if we get here...
|
||||||
Assert(ptrType->IsVaryingType());
|
AssertPos(currentPos, ptrType->IsVaryingType());
|
||||||
|
|
||||||
const Type *returnType = ptrType->GetBaseType()->GetAsVaryingType();
|
const Type *returnType = ptrType->GetBaseType()->GetAsVaryingType();
|
||||||
llvm::Type *llvmReturnType = returnType->LLVMType(g->ctx);
|
llvm::Type *llvmReturnType = returnType->LLVMType(g->ctx);
|
||||||
@@ -2534,13 +2534,13 @@ FunctionEmitContext::gather(llvm::Value *ptr, const PointerType *ptrType,
|
|||||||
funcName = g->target.is32Bit ? "__pseudo_gather32_16" :
|
funcName = g->target.is32Bit ? "__pseudo_gather32_16" :
|
||||||
"__pseudo_gather64_16";
|
"__pseudo_gather64_16";
|
||||||
else {
|
else {
|
||||||
Assert(llvmReturnType == LLVMTypes::Int8VectorType);
|
AssertPos(currentPos, llvmReturnType == LLVMTypes::Int8VectorType);
|
||||||
funcName = g->target.is32Bit ? "__pseudo_gather32_8" :
|
funcName = g->target.is32Bit ? "__pseudo_gather32_8" :
|
||||||
"__pseudo_gather64_8";
|
"__pseudo_gather64_8";
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Function *gatherFunc = m->module->getFunction(funcName);
|
llvm::Function *gatherFunc = m->module->getFunction(funcName);
|
||||||
Assert(gatherFunc != NULL);
|
AssertPos(currentPos, gatherFunc != NULL);
|
||||||
|
|
||||||
llvm::Value *call = CallInst(gatherFunc, NULL, ptr, mask, name);
|
llvm::Value *call = CallInst(gatherFunc, NULL, ptr, mask, name);
|
||||||
|
|
||||||
@@ -2591,7 +2591,7 @@ FunctionEmitContext::AllocaInst(llvm::Type *llvmType,
|
|||||||
const char *name, int align,
|
const char *name, int align,
|
||||||
bool atEntryBlock) {
|
bool atEntryBlock) {
|
||||||
if (llvmType == NULL) {
|
if (llvmType == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2600,7 +2600,7 @@ FunctionEmitContext::AllocaInst(llvm::Type *llvmType,
|
|||||||
// We usually insert it right before the jump instruction at the
|
// We usually insert it right before the jump instruction at the
|
||||||
// end of allocaBlock
|
// end of allocaBlock
|
||||||
llvm::Instruction *retInst = allocaBlock->getTerminator();
|
llvm::Instruction *retInst = allocaBlock->getTerminator();
|
||||||
Assert(retInst);
|
AssertPos(currentPos, retInst);
|
||||||
inst = new llvm::AllocaInst(llvmType, name ? name : "", retInst);
|
inst = new llvm::AllocaInst(llvmType, name ? name : "", retInst);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2636,12 +2636,12 @@ void
|
|||||||
FunctionEmitContext::maskedStore(llvm::Value *value, llvm::Value *ptr,
|
FunctionEmitContext::maskedStore(llvm::Value *value, llvm::Value *ptr,
|
||||||
const Type *ptrType, llvm::Value *mask) {
|
const Type *ptrType, llvm::Value *mask) {
|
||||||
if (value == NULL || ptr == NULL) {
|
if (value == NULL || ptr == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert(CastType<PointerType>(ptrType) != NULL);
|
AssertPos(currentPos, CastType<PointerType>(ptrType) != NULL);
|
||||||
Assert(ptrType->IsUniformType());
|
AssertPos(currentPos, ptrType->IsUniformType());
|
||||||
|
|
||||||
const Type *valueType = ptrType->GetBaseType();
|
const Type *valueType = ptrType->GetBaseType();
|
||||||
const CollectionType *collectionType = CastType<CollectionType>(valueType);
|
const CollectionType *collectionType = CastType<CollectionType>(valueType);
|
||||||
@@ -2662,7 +2662,7 @@ FunctionEmitContext::maskedStore(llvm::Value *value, llvm::Value *ptr,
|
|||||||
|
|
||||||
// We must have a regular atomic, enumerator, or pointer type at this
|
// We must have a regular atomic, enumerator, or pointer type at this
|
||||||
// point.
|
// point.
|
||||||
Assert(Type::IsBasicType(valueType));
|
AssertPos(currentPos, Type::IsBasicType(valueType));
|
||||||
valueType = valueType->GetAsNonConstType();
|
valueType = valueType->GetAsNonConstType();
|
||||||
|
|
||||||
// Figure out if we need a 8, 16, 32 or 64-bit masked store.
|
// Figure out if we need a 8, 16, 32 or 64-bit masked store.
|
||||||
@@ -2672,7 +2672,7 @@ FunctionEmitContext::maskedStore(llvm::Value *value, llvm::Value *ptr,
|
|||||||
if (pt != NULL) {
|
if (pt != NULL) {
|
||||||
if (pt->IsSlice()) {
|
if (pt->IsSlice()) {
|
||||||
// Masked store of (varying) slice pointer.
|
// Masked store of (varying) slice pointer.
|
||||||
Assert(pt->IsVaryingType());
|
AssertPos(currentPos, pt->IsVaryingType());
|
||||||
|
|
||||||
// First, extract the pointer from the slice struct and masked
|
// First, extract the pointer from the slice struct and masked
|
||||||
// store that.
|
// store that.
|
||||||
@@ -2742,7 +2742,7 @@ FunctionEmitContext::maskedStore(llvm::Value *value, llvm::Value *ptr,
|
|||||||
ptr = BitCastInst(ptr, LLVMTypes::Int8VectorPointerType,
|
ptr = BitCastInst(ptr, LLVMTypes::Int8VectorPointerType,
|
||||||
LLVMGetName(ptr, "_to_int8vecptr"));
|
LLVMGetName(ptr, "_to_int8vecptr"));
|
||||||
}
|
}
|
||||||
Assert(maskedStoreFunc != NULL);
|
AssertPos(currentPos, maskedStoreFunc != NULL);
|
||||||
|
|
||||||
std::vector<llvm::Value *> args;
|
std::vector<llvm::Value *> args;
|
||||||
args.push_back(ptr);
|
args.push_back(ptr);
|
||||||
@@ -2764,8 +2764,8 @@ FunctionEmitContext::scatter(llvm::Value *value, llvm::Value *ptr,
|
|||||||
const Type *valueType, const Type *origPt,
|
const Type *valueType, const Type *origPt,
|
||||||
llvm::Value *mask) {
|
llvm::Value *mask) {
|
||||||
const PointerType *ptrType = CastType<PointerType>(origPt);
|
const PointerType *ptrType = CastType<PointerType>(origPt);
|
||||||
Assert(ptrType != NULL);
|
AssertPos(currentPos, ptrType != NULL);
|
||||||
Assert(ptrType->IsVaryingType());
|
AssertPos(currentPos, ptrType->IsVaryingType());
|
||||||
|
|
||||||
const CollectionType *srcCollectionType =
|
const CollectionType *srcCollectionType =
|
||||||
CastType<CollectionType>(valueType);
|
CastType<CollectionType>(valueType);
|
||||||
@@ -2780,7 +2780,7 @@ FunctionEmitContext::scatter(llvm::Value *value, llvm::Value *ptr,
|
|||||||
// instances of the struct type, etc.
|
// instances of the struct type, etc.
|
||||||
const CollectionType *dstCollectionType =
|
const CollectionType *dstCollectionType =
|
||||||
CastType<CollectionType>(ptrType->GetBaseType());
|
CastType<CollectionType>(ptrType->GetBaseType());
|
||||||
Assert(dstCollectionType != NULL);
|
AssertPos(currentPos, dstCollectionType != NULL);
|
||||||
|
|
||||||
// Scatter the collection elements individually
|
// Scatter the collection elements individually
|
||||||
for (int i = 0; i < srcCollectionType->GetElementCount(); ++i) {
|
for (int i = 0; i < srcCollectionType->GetElementCount(); ++i) {
|
||||||
@@ -2827,7 +2827,7 @@ FunctionEmitContext::scatter(llvm::Value *value, llvm::Value *ptr,
|
|||||||
const PointerType *pt = CastType<PointerType>(valueType);
|
const PointerType *pt = CastType<PointerType>(valueType);
|
||||||
|
|
||||||
// And everything should be a pointer or atomic from here on out...
|
// And everything should be a pointer or atomic from here on out...
|
||||||
Assert(pt != NULL || CastType<AtomicType>(valueType) != NULL);
|
AssertPos(currentPos, pt != NULL || CastType<AtomicType>(valueType) != NULL);
|
||||||
|
|
||||||
llvm::Type *type = value->getType();
|
llvm::Type *type = value->getType();
|
||||||
const char *funcName = NULL;
|
const char *funcName = NULL;
|
||||||
@@ -2854,7 +2854,7 @@ FunctionEmitContext::scatter(llvm::Value *value, llvm::Value *ptr,
|
|||||||
"__pseudo_scatter64_8";
|
"__pseudo_scatter64_8";
|
||||||
|
|
||||||
llvm::Function *scatterFunc = m->module->getFunction(funcName);
|
llvm::Function *scatterFunc = m->module->getFunction(funcName);
|
||||||
Assert(scatterFunc != NULL);
|
AssertPos(currentPos, scatterFunc != NULL);
|
||||||
|
|
||||||
AddInstrumentationPoint("scatter");
|
AddInstrumentationPoint("scatter");
|
||||||
|
|
||||||
@@ -2873,7 +2873,7 @@ void
|
|||||||
FunctionEmitContext::StoreInst(llvm::Value *value, llvm::Value *ptr) {
|
FunctionEmitContext::StoreInst(llvm::Value *value, llvm::Value *ptr) {
|
||||||
if (value == NULL || ptr == NULL) {
|
if (value == NULL || ptr == NULL) {
|
||||||
// may happen due to error elsewhere
|
// may happen due to error elsewhere
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2898,7 +2898,7 @@ FunctionEmitContext::StoreInst(llvm::Value *value, llvm::Value *ptr,
|
|||||||
const Type *ptrRefType) {
|
const Type *ptrRefType) {
|
||||||
if (value == NULL || ptr == NULL) {
|
if (value == NULL || ptr == NULL) {
|
||||||
// may happen due to error elsewhere
|
// may happen due to error elsewhere
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2907,7 +2907,7 @@ FunctionEmitContext::StoreInst(llvm::Value *value, llvm::Value *ptr,
|
|||||||
ptrType = PointerType::GetUniform(ptrRefType->GetReferenceTarget());
|
ptrType = PointerType::GetUniform(ptrRefType->GetReferenceTarget());
|
||||||
else {
|
else {
|
||||||
ptrType = CastType<PointerType>(ptrRefType);
|
ptrType = CastType<PointerType>(ptrRefType);
|
||||||
Assert(ptrType != NULL);
|
AssertPos(currentPos, ptrType != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out what kind of store we're doing here
|
// Figure out what kind of store we're doing here
|
||||||
@@ -2926,7 +2926,7 @@ FunctionEmitContext::StoreInst(llvm::Value *value, llvm::Value *ptr,
|
|||||||
maskedStore(value, ptr, ptrType, mask);
|
maskedStore(value, ptr, ptrType, mask);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Assert(ptrType->IsVaryingType());
|
AssertPos(currentPos, ptrType->IsVaryingType());
|
||||||
// We have a varying ptr (an array of pointers), so it's time to
|
// We have a varying ptr (an array of pointers), so it's time to
|
||||||
// scatter
|
// scatter
|
||||||
scatter(value, ptr, valueType, ptrType, GetFullMask());
|
scatter(value, ptr, valueType, ptrType, GetFullMask());
|
||||||
@@ -2940,7 +2940,7 @@ void
|
|||||||
FunctionEmitContext::storeUniformToSOA(llvm::Value *value, llvm::Value *ptr,
|
FunctionEmitContext::storeUniformToSOA(llvm::Value *value, llvm::Value *ptr,
|
||||||
llvm::Value *mask, const Type *valueType,
|
llvm::Value *mask, const Type *valueType,
|
||||||
const PointerType *ptrType) {
|
const PointerType *ptrType) {
|
||||||
Assert(Type::EqualIgnoringConst(ptrType->GetBaseType()->GetAsUniformType(),
|
AssertPos(currentPos, Type::EqualIgnoringConst(ptrType->GetBaseType()->GetAsUniformType(),
|
||||||
valueType));
|
valueType));
|
||||||
|
|
||||||
const CollectionType *ct = CastType<CollectionType>(valueType);
|
const CollectionType *ct = CastType<CollectionType>(valueType);
|
||||||
@@ -2959,7 +2959,7 @@ FunctionEmitContext::storeUniformToSOA(llvm::Value *value, llvm::Value *ptr,
|
|||||||
else {
|
else {
|
||||||
// We're finally at a leaf SOA array; apply the slice offset and
|
// We're finally at a leaf SOA array; apply the slice offset and
|
||||||
// then we can do a final regular store
|
// then we can do a final regular store
|
||||||
Assert(Type::IsBasicType(valueType));
|
AssertPos(currentPos, Type::IsBasicType(valueType));
|
||||||
ptr = lFinalSliceOffset(this, ptr, &ptrType);
|
ptr = lFinalSliceOffset(this, ptr, &ptrType);
|
||||||
StoreInst(value, ptr);
|
StoreInst(value, ptr);
|
||||||
}
|
}
|
||||||
@@ -2972,7 +2972,7 @@ FunctionEmitContext::MemcpyInst(llvm::Value *dest, llvm::Value *src,
|
|||||||
dest = BitCastInst(dest, LLVMTypes::VoidPointerType);
|
dest = BitCastInst(dest, LLVMTypes::VoidPointerType);
|
||||||
src = BitCastInst(src, LLVMTypes::VoidPointerType);
|
src = BitCastInst(src, LLVMTypes::VoidPointerType);
|
||||||
if (count->getType() != LLVMTypes::Int64Type) {
|
if (count->getType() != LLVMTypes::Int64Type) {
|
||||||
Assert(count->getType() == LLVMTypes::Int32Type);
|
AssertPos(currentPos, count->getType() == LLVMTypes::Int32Type);
|
||||||
count = ZExtInst(count, LLVMTypes::Int64Type, "count_to_64");
|
count = ZExtInst(count, LLVMTypes::Int64Type, "count_to_64");
|
||||||
}
|
}
|
||||||
if (align == NULL)
|
if (align == NULL)
|
||||||
@@ -2983,8 +2983,8 @@ FunctionEmitContext::MemcpyInst(llvm::Value *dest, llvm::Value *src,
|
|||||||
LLVMTypes::VoidType, LLVMTypes::VoidPointerType,
|
LLVMTypes::VoidType, LLVMTypes::VoidPointerType,
|
||||||
LLVMTypes::VoidPointerType, LLVMTypes::Int64Type,
|
LLVMTypes::VoidPointerType, LLVMTypes::Int64Type,
|
||||||
LLVMTypes::Int32Type, LLVMTypes::BoolType, NULL);
|
LLVMTypes::Int32Type, LLVMTypes::BoolType, NULL);
|
||||||
Assert(mcFunc != NULL);
|
AssertPos(currentPos, mcFunc != NULL);
|
||||||
Assert(llvm::isa<llvm::Function>(mcFunc));
|
AssertPos(currentPos, llvm::isa<llvm::Function>(mcFunc));
|
||||||
|
|
||||||
std::vector<llvm::Value *> args;
|
std::vector<llvm::Value *> args;
|
||||||
args.push_back(dest);
|
args.push_back(dest);
|
||||||
@@ -3008,7 +3008,7 @@ FunctionEmitContext::BranchInst(llvm::BasicBlock *trueBlock,
|
|||||||
llvm::BasicBlock *falseBlock,
|
llvm::BasicBlock *falseBlock,
|
||||||
llvm::Value *test) {
|
llvm::Value *test) {
|
||||||
if (test == NULL) {
|
if (test == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3021,7 +3021,7 @@ FunctionEmitContext::BranchInst(llvm::BasicBlock *trueBlock,
|
|||||||
llvm::Value *
|
llvm::Value *
|
||||||
FunctionEmitContext::ExtractInst(llvm::Value *v, int elt, const char *name) {
|
FunctionEmitContext::ExtractInst(llvm::Value *v, int elt, const char *name) {
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3045,7 +3045,7 @@ llvm::Value *
|
|||||||
FunctionEmitContext::InsertInst(llvm::Value *v, llvm::Value *eltVal, int elt,
|
FunctionEmitContext::InsertInst(llvm::Value *v, llvm::Value *eltVal, int elt,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (v == NULL || eltVal == NULL) {
|
if (v == NULL || eltVal == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3080,7 +3080,7 @@ llvm::Instruction *
|
|||||||
FunctionEmitContext::SelectInst(llvm::Value *test, llvm::Value *val0,
|
FunctionEmitContext::SelectInst(llvm::Value *test, llvm::Value *val0,
|
||||||
llvm::Value *val1, const char *name) {
|
llvm::Value *val1, const char *name) {
|
||||||
if (test == NULL || val0 == NULL || val1 == NULL) {
|
if (test == NULL || val0 == NULL || val1 == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3123,7 +3123,7 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType,
|
|||||||
const std::vector<llvm::Value *> &args,
|
const std::vector<llvm::Value *> &args,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
if (func == NULL) {
|
if (func == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3132,7 +3132,7 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType,
|
|||||||
// isn't the case for things like intrinsics, builtins, and extern "C"
|
// isn't the case for things like intrinsics, builtins, and extern "C"
|
||||||
// functions from the application. Add the mask if it's needed.
|
// functions from the application. Add the mask if it's needed.
|
||||||
unsigned int calleeArgCount = lCalleeArgCount(func, funcType);
|
unsigned int calleeArgCount = lCalleeArgCount(func, funcType);
|
||||||
Assert(argVals.size() + 1 == calleeArgCount ||
|
AssertPos(currentPos, argVals.size() + 1 == calleeArgCount ||
|
||||||
argVals.size() == calleeArgCount);
|
argVals.size() == calleeArgCount);
|
||||||
if (argVals.size() + 1 == calleeArgCount)
|
if (argVals.size() + 1 == calleeArgCount)
|
||||||
argVals.push_back(GetFullMask());
|
argVals.push_back(GetFullMask());
|
||||||
@@ -3197,7 +3197,7 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType,
|
|||||||
llvm::Value *currentMask = LoadInst(maskPtr);
|
llvm::Value *currentMask = LoadInst(maskPtr);
|
||||||
llvm::Function *cttz =
|
llvm::Function *cttz =
|
||||||
m->module->getFunction("__count_trailing_zeros_i32");
|
m->module->getFunction("__count_trailing_zeros_i32");
|
||||||
Assert(cttz != NULL);
|
AssertPos(currentPos, cttz != NULL);
|
||||||
llvm::Value *firstLane = CallInst(cttz, NULL, LaneMask(currentMask),
|
llvm::Value *firstLane = CallInst(cttz, NULL, LaneMask(currentMask),
|
||||||
"first_lane");
|
"first_lane");
|
||||||
|
|
||||||
@@ -3245,12 +3245,12 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType,
|
|||||||
// accumulate the result using the call mask.
|
// accumulate the result using the call mask.
|
||||||
if (callResult != NULL &&
|
if (callResult != NULL &&
|
||||||
callResult->getType() != LLVMTypes::VoidType) {
|
callResult->getType() != LLVMTypes::VoidType) {
|
||||||
Assert(resultPtr != NULL);
|
AssertPos(currentPos, resultPtr != NULL);
|
||||||
StoreInst(callResult, resultPtr, callMask, returnType,
|
StoreInst(callResult, resultPtr, callMask, returnType,
|
||||||
PointerType::GetUniform(returnType));
|
PointerType::GetUniform(returnType));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Assert(resultPtr == NULL);
|
AssertPos(currentPos, resultPtr == NULL);
|
||||||
|
|
||||||
// Update the mask to turn off the program instances for which
|
// Update the mask to turn off the program instances for which
|
||||||
// we just called the function.
|
// we just called the function.
|
||||||
@@ -3310,7 +3310,7 @@ FunctionEmitContext::ReturnInst() {
|
|||||||
rinst = llvm::ReturnInst::Create(*g->ctx, retVal, bblock);
|
rinst = llvm::ReturnInst::Create(*g->ctx, retVal, bblock);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Assert(Type::Equal(function->GetReturnType(), AtomicType::Void));
|
AssertPos(currentPos, Type::Equal(function->GetReturnType(), AtomicType::Void));
|
||||||
rinst = llvm::ReturnInst::Create(*g->ctx, bblock);
|
rinst = llvm::ReturnInst::Create(*g->ctx, bblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3325,25 +3325,25 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
|||||||
std::vector<llvm::Value *> &argVals,
|
std::vector<llvm::Value *> &argVals,
|
||||||
llvm::Value *launchCount) {
|
llvm::Value *launchCount) {
|
||||||
if (callee == NULL) {
|
if (callee == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(currentPos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
launchedTasks = true;
|
launchedTasks = true;
|
||||||
|
|
||||||
Assert(llvm::isa<llvm::Function>(callee));
|
AssertPos(currentPos, llvm::isa<llvm::Function>(callee));
|
||||||
llvm::Type *argType =
|
llvm::Type *argType =
|
||||||
(llvm::dyn_cast<llvm::Function>(callee))->arg_begin()->getType();
|
(llvm::dyn_cast<llvm::Function>(callee))->arg_begin()->getType();
|
||||||
Assert(llvm::PointerType::classof(argType));
|
AssertPos(currentPos, llvm::PointerType::classof(argType));
|
||||||
llvm::PointerType *pt =
|
llvm::PointerType *pt =
|
||||||
llvm::dyn_cast<llvm::PointerType>(argType);
|
llvm::dyn_cast<llvm::PointerType>(argType);
|
||||||
Assert(llvm::StructType::classof(pt->getElementType()));
|
AssertPos(currentPos, llvm::StructType::classof(pt->getElementType()));
|
||||||
llvm::StructType *argStructType =
|
llvm::StructType *argStructType =
|
||||||
static_cast<llvm::StructType *>(pt->getElementType());
|
static_cast<llvm::StructType *>(pt->getElementType());
|
||||||
Assert(argStructType->getNumElements() == argVals.size() + 1);
|
AssertPos(currentPos, argStructType->getNumElements() == argVals.size() + 1);
|
||||||
|
|
||||||
llvm::Function *falloc = m->module->getFunction("ISPCAlloc");
|
llvm::Function *falloc = m->module->getFunction("ISPCAlloc");
|
||||||
Assert(falloc != NULL);
|
AssertPos(currentPos, falloc != NULL);
|
||||||
llvm::Value *structSize = g->target.SizeOf(argStructType, bblock);
|
llvm::Value *structSize = g->target.SizeOf(argStructType, bblock);
|
||||||
if (structSize->getType() != LLVMTypes::Int64Type)
|
if (structSize->getType() != LLVMTypes::Int64Type)
|
||||||
// ISPCAlloc expects the size as an uint64_t, but on 32-bit
|
// ISPCAlloc expects the size as an uint64_t, but on 32-bit
|
||||||
@@ -3378,7 +3378,7 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
|||||||
// argument block we just filled in
|
// argument block we just filled in
|
||||||
llvm::Value *fptr = BitCastInst(callee, LLVMTypes::VoidPointerType);
|
llvm::Value *fptr = BitCastInst(callee, LLVMTypes::VoidPointerType);
|
||||||
llvm::Function *flaunch = m->module->getFunction("ISPCLaunch");
|
llvm::Function *flaunch = m->module->getFunction("ISPCLaunch");
|
||||||
Assert(flaunch != NULL);
|
AssertPos(currentPos, flaunch != NULL);
|
||||||
std::vector<llvm::Value *> args;
|
std::vector<llvm::Value *> args;
|
||||||
args.push_back(launchGroupHandlePtr);
|
args.push_back(launchGroupHandlePtr);
|
||||||
args.push_back(fptr);
|
args.push_back(fptr);
|
||||||
@@ -3427,7 +3427,7 @@ FunctionEmitContext::addVaryingOffsetsIfNeeded(llvm::Value *ptr,
|
|||||||
const Type *ptrType) {
|
const Type *ptrType) {
|
||||||
// This should only be called for varying pointers
|
// This should only be called for varying pointers
|
||||||
const PointerType *pt = CastType<PointerType>(ptrType);
|
const PointerType *pt = CastType<PointerType>(ptrType);
|
||||||
Assert(pt && pt->IsVaryingType());
|
AssertPos(currentPos, pt && pt->IsVaryingType());
|
||||||
|
|
||||||
const Type *baseType = ptrType->GetBaseType();
|
const Type *baseType = ptrType->GetBaseType();
|
||||||
if (Type::IsBasicType(baseType) == false)
|
if (Type::IsBasicType(baseType) == false)
|
||||||
@@ -3464,7 +3464,7 @@ FunctionEmitContext::addVaryingOffsetsIfNeeded(llvm::Value *ptr,
|
|||||||
|
|
||||||
CFInfo *
|
CFInfo *
|
||||||
FunctionEmitContext::popCFState() {
|
FunctionEmitContext::popCFState() {
|
||||||
Assert(controlFlowInfo.size() > 0);
|
AssertPos(currentPos, controlFlowInfo.size() > 0);
|
||||||
CFInfo *ci = controlFlowInfo.back();
|
CFInfo *ci = controlFlowInfo.back();
|
||||||
controlFlowInfo.pop_back();
|
controlFlowInfo.pop_back();
|
||||||
|
|
||||||
@@ -3488,7 +3488,7 @@ FunctionEmitContext::popCFState() {
|
|||||||
loopMask = ci->savedLoopMask;
|
loopMask = ci->savedLoopMask;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Assert(ci->IsIf());
|
AssertPos(currentPos, ci->IsIf());
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
decl.cpp
16
decl.cpp
@@ -231,7 +231,7 @@ Declarator::InitFromDeclSpecs(DeclSpecs *ds) {
|
|||||||
InitFromType(baseType, ds);
|
InitFromType(baseType, ds);
|
||||||
|
|
||||||
if (type == NULL) {
|
if (type == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(pos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,8 +319,8 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
|
|||||||
if (kind == DK_BASE) {
|
if (kind == DK_BASE) {
|
||||||
// All of the type qualifiers should be in the DeclSpecs for the
|
// All of the type qualifiers should be in the DeclSpecs for the
|
||||||
// base declarator
|
// base declarator
|
||||||
Assert(typeQualifiers == 0);
|
AssertPos(pos, typeQualifiers == 0);
|
||||||
Assert(child == NULL);
|
AssertPos(pos, child == NULL);
|
||||||
type = baseType;
|
type = baseType;
|
||||||
}
|
}
|
||||||
else if (kind == DK_POINTER) {
|
else if (kind == DK_POINTER) {
|
||||||
@@ -398,7 +398,7 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
|
|||||||
Declaration *d = functionParams[i];
|
Declaration *d = functionParams[i];
|
||||||
|
|
||||||
if (d == NULL) {
|
if (d == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(pos, m->errorCount > 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (d->declarators.size() == 0) {
|
if (d->declarators.size() == 0) {
|
||||||
@@ -408,10 +408,10 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
|
|||||||
d->declarators[0]->InitFromDeclSpecs(d->declSpecs);
|
d->declarators[0]->InitFromDeclSpecs(d->declSpecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert(d->declarators.size() == 1);
|
AssertPos(pos, d->declarators.size() == 1);
|
||||||
Declarator *decl = d->declarators[0];
|
Declarator *decl = d->declarators[0];
|
||||||
if (decl == NULL || decl->type == NULL) {
|
if (decl == NULL || decl->type == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(pos, m->errorCount > 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,7 +446,7 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
|
|||||||
// significant problem.)
|
// significant problem.)
|
||||||
const Type *targetType = at->GetElementType();
|
const Type *targetType = at->GetElementType();
|
||||||
if (targetType == NULL) {
|
if (targetType == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(pos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -525,7 +525,7 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (child == NULL) {
|
if (child == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(pos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
ispc.h
24
ispc.h
@@ -58,16 +58,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define Assert(expr) \
|
|
||||||
((void)((expr) ? 0 : __Assert (#expr, __FILE__, __LINE__)))
|
|
||||||
#define __Assert(expr, file, line) \
|
|
||||||
((void)fprintf(stderr, "%s:%u: Assertion failed: \"%s\"\n" \
|
|
||||||
"***\n*** Please file a bug report at " \
|
|
||||||
"https://github.com/ispc/ispc/issues\n*** (Including as much " \
|
|
||||||
"information as you can about how to reproduce this error).\n" \
|
|
||||||
"*** You have apparently encountered a bug in the compiler that " \
|
|
||||||
"we'd like to fix!\n***\n", file, line, expr), abort(), 0)
|
|
||||||
|
|
||||||
/** @def ISPC_MAX_NVEC maximum vector size of any of the compliation
|
/** @def ISPC_MAX_NVEC maximum vector size of any of the compliation
|
||||||
targets.
|
targets.
|
||||||
*/
|
*/
|
||||||
@@ -145,11 +135,25 @@ struct SourcePos {
|
|||||||
bool operator==(const SourcePos &p2) const;
|
bool operator==(const SourcePos &p2) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Returns a SourcePos that encompasses the extent of both of the given
|
/** Returns a SourcePos that encompasses the extent of both of the given
|
||||||
extents. */
|
extents. */
|
||||||
SourcePos Union(const SourcePos &p1, const SourcePos &p2);
|
SourcePos Union(const SourcePos &p1, const SourcePos &p2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
|
||||||
|
extern void DoAssert(const char *file, int line, const char *expr);
|
||||||
|
extern void DoAssertPos(SourcePos pos, const char *file, int line, const char *expr);
|
||||||
|
|
||||||
|
#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)))
|
||||||
|
|
||||||
|
|
||||||
/** @brief Structure that defines a compilation target
|
/** @brief Structure that defines a compilation target
|
||||||
|
|
||||||
This structure defines a compilation target for the ispc compiler.
|
This structure defines a compilation target for the ispc compiler.
|
||||||
|
|||||||
42
parse.yy
42
parse.yy
@@ -391,7 +391,7 @@ argument_expression_list
|
|||||||
{
|
{
|
||||||
ExprList *argList = dynamic_cast<ExprList *>($1);
|
ExprList *argList = dynamic_cast<ExprList *>($1);
|
||||||
if (argList == NULL) {
|
if (argList == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
argList = new ExprList(@3);
|
argList = new ExprList(@3);
|
||||||
}
|
}
|
||||||
argList->exprs.push_back($3);
|
argList->exprs.push_back($3);
|
||||||
@@ -623,13 +623,13 @@ declaration_statement
|
|||||||
: declaration
|
: declaration
|
||||||
{
|
{
|
||||||
if ($1 == NULL) {
|
if ($1 == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
$$ = NULL;
|
$$ = NULL;
|
||||||
}
|
}
|
||||||
else if ($1->declSpecs->storageClass == SC_TYPEDEF) {
|
else if ($1->declSpecs->storageClass == SC_TYPEDEF) {
|
||||||
for (unsigned int i = 0; i < $1->declarators.size(); ++i) {
|
for (unsigned int i = 0; i < $1->declarators.size(); ++i) {
|
||||||
if ($1->declarators[i] == NULL)
|
if ($1->declarators[i] == NULL)
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
else
|
else
|
||||||
m->AddTypeDef($1->declarators[i]->name,
|
m->AddTypeDef($1->declarators[i]->name,
|
||||||
$1->declarators[i]->type,
|
$1->declarators[i]->type,
|
||||||
@@ -789,7 +789,7 @@ init_declarator_list
|
|||||||
{
|
{
|
||||||
std::vector<Declarator *> *dl = (std::vector<Declarator *> *)$1;
|
std::vector<Declarator *> *dl = (std::vector<Declarator *> *)$1;
|
||||||
if (dl == NULL) {
|
if (dl == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
dl = new std::vector<Declarator *>;
|
dl = new std::vector<Declarator *>;
|
||||||
}
|
}
|
||||||
if ($3 != NULL)
|
if ($3 != NULL)
|
||||||
@@ -918,7 +918,7 @@ struct_declaration_list
|
|||||||
{
|
{
|
||||||
std::vector<StructDeclaration *> *sdl = (std::vector<StructDeclaration *> *)$1;
|
std::vector<StructDeclaration *> *sdl = (std::vector<StructDeclaration *> *)$1;
|
||||||
if (sdl == NULL) {
|
if (sdl == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
sdl = new std::vector<StructDeclaration *>;
|
sdl = new std::vector<StructDeclaration *>;
|
||||||
}
|
}
|
||||||
if ($2 != NULL)
|
if ($2 != NULL)
|
||||||
@@ -1013,7 +1013,7 @@ struct_declarator_list
|
|||||||
{
|
{
|
||||||
std::vector<Declarator *> *sdl = (std::vector<Declarator *> *)$1;
|
std::vector<Declarator *> *sdl = (std::vector<Declarator *> *)$1;
|
||||||
if (sdl == NULL) {
|
if (sdl == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
sdl = new std::vector<Declarator *>;
|
sdl = new std::vector<Declarator *>;
|
||||||
}
|
}
|
||||||
if ($3 != NULL)
|
if ($3 != NULL)
|
||||||
@@ -1087,7 +1087,7 @@ enumerator_list
|
|||||||
{
|
{
|
||||||
std::vector<Symbol *> *symList = $1;
|
std::vector<Symbol *> *symList = $1;
|
||||||
if (symList == NULL) {
|
if (symList == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
symList = new std::vector<Symbol *>;
|
symList = new std::vector<Symbol *>;
|
||||||
}
|
}
|
||||||
if ($3 != NULL)
|
if ($3 != NULL)
|
||||||
@@ -1487,7 +1487,7 @@ initializer_list
|
|||||||
{
|
{
|
||||||
ExprList *exprList = $1;
|
ExprList *exprList = $1;
|
||||||
if (exprList == NULL) {
|
if (exprList == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
exprList = new ExprList(@3);
|
exprList = new ExprList(@3);
|
||||||
}
|
}
|
||||||
exprList->exprs.push_back($3);
|
exprList->exprs.push_back($3);
|
||||||
@@ -1558,7 +1558,7 @@ statement_list
|
|||||||
{
|
{
|
||||||
StmtList *sl = (StmtList *)$1;
|
StmtList *sl = (StmtList *)$1;
|
||||||
if (sl == NULL) {
|
if (sl == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
sl = new StmtList(@2);
|
sl = new StmtList(@2);
|
||||||
}
|
}
|
||||||
sl->Add($2);
|
sl->Add($2);
|
||||||
@@ -1670,7 +1670,7 @@ foreach_dimension_list
|
|||||||
{
|
{
|
||||||
std::vector<ForeachDimension *> *dv = $1;
|
std::vector<ForeachDimension *> *dv = $1;
|
||||||
if (dv == NULL) {
|
if (dv == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
dv = new std::vector<ForeachDimension *>;
|
dv = new std::vector<ForeachDimension *>;
|
||||||
}
|
}
|
||||||
if ($3 != NULL)
|
if ($3 != NULL)
|
||||||
@@ -1708,7 +1708,7 @@ iteration_statement
|
|||||||
{
|
{
|
||||||
std::vector<ForeachDimension *> *dims = $3;
|
std::vector<ForeachDimension *> *dims = $3;
|
||||||
if (dims == NULL) {
|
if (dims == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@3, m->errorCount > 0);
|
||||||
dims = new std::vector<ForeachDimension *>;
|
dims = new std::vector<ForeachDimension *>;
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < dims->size(); ++i)
|
for (unsigned int i = 0; i < dims->size(); ++i)
|
||||||
@@ -1718,7 +1718,7 @@ iteration_statement
|
|||||||
{
|
{
|
||||||
std::vector<ForeachDimension *> *dims = $3;
|
std::vector<ForeachDimension *> *dims = $3;
|
||||||
if (dims == NULL) {
|
if (dims == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@3, m->errorCount > 0);
|
||||||
dims = new std::vector<ForeachDimension *>;
|
dims = new std::vector<ForeachDimension *>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1736,7 +1736,7 @@ iteration_statement
|
|||||||
{
|
{
|
||||||
std::vector<ForeachDimension *> *dims = $3;
|
std::vector<ForeachDimension *> *dims = $3;
|
||||||
if (dims == NULL) {
|
if (dims == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@3, m->errorCount > 0);
|
||||||
dims = new std::vector<ForeachDimension *>;
|
dims = new std::vector<ForeachDimension *>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1747,7 +1747,7 @@ iteration_statement
|
|||||||
{
|
{
|
||||||
std::vector<ForeachDimension *> *dims = $3;
|
std::vector<ForeachDimension *> *dims = $3;
|
||||||
if (dims == NULL) {
|
if (dims == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
dims = new std::vector<ForeachDimension *>;
|
dims = new std::vector<ForeachDimension *>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1861,7 +1861,7 @@ function_definition
|
|||||||
$2->InitFromDeclSpecs($1);
|
$2->InitFromDeclSpecs($1);
|
||||||
const FunctionType *funcType = CastType<FunctionType>($2->type);
|
const FunctionType *funcType = CastType<FunctionType>($2->type);
|
||||||
if (funcType == NULL)
|
if (funcType == NULL)
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(@1, m->errorCount > 0);
|
||||||
else {
|
else {
|
||||||
Stmt *code = $4;
|
Stmt *code = $4;
|
||||||
if (code == NULL) code = new StmtList(@4);
|
if (code == NULL) code = new StmtList(@4);
|
||||||
@@ -2010,7 +2010,7 @@ lAddFunctionParams(Declarator *decl) {
|
|||||||
m->symbolTable->PushScope();
|
m->symbolTable->PushScope();
|
||||||
|
|
||||||
if (decl == NULL) {
|
if (decl == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(decl->pos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2018,7 +2018,7 @@ lAddFunctionParams(Declarator *decl) {
|
|||||||
while (decl->kind != DK_FUNCTION && decl->child != NULL)
|
while (decl->kind != DK_FUNCTION && decl->child != NULL)
|
||||||
decl = decl->child;
|
decl = decl->child;
|
||||||
if (decl->kind != DK_FUNCTION) {
|
if (decl->kind != DK_FUNCTION) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(decl->pos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2028,14 +2028,14 @@ lAddFunctionParams(Declarator *decl) {
|
|||||||
Assert(pdecl != NULL && pdecl->declarators.size() == 1);
|
Assert(pdecl != NULL && pdecl->declarators.size() == 1);
|
||||||
Declarator *declarator = pdecl->declarators[0];
|
Declarator *declarator = pdecl->declarators[0];
|
||||||
if (declarator == NULL)
|
if (declarator == NULL)
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(decl->pos, m->errorCount > 0);
|
||||||
else {
|
else {
|
||||||
Symbol *sym = new Symbol(declarator->name, declarator->pos,
|
Symbol *sym = new Symbol(declarator->name, declarator->pos,
|
||||||
declarator->type, declarator->storageClass);
|
declarator->type, declarator->storageClass);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
bool ok = m->symbolTable->AddVariable(sym);
|
bool ok = m->symbolTable->AddVariable(sym);
|
||||||
if (ok == false)
|
if (ok == false)
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(decl->pos, m->errorCount > 0);
|
||||||
#else
|
#else
|
||||||
m->symbolTable->AddVariable(sym);
|
m->symbolTable->AddVariable(sym);
|
||||||
#endif
|
#endif
|
||||||
@@ -2189,7 +2189,7 @@ lFinalizeEnumeratorSymbols(std::vector<Symbol *> &enums,
|
|||||||
if (enums[i]->constValue != NULL) {
|
if (enums[i]->constValue != NULL) {
|
||||||
/* Already has a value, so first update nextVal with it. */
|
/* Already has a value, so first update nextVal with it. */
|
||||||
int count = enums[i]->constValue->AsUInt32(&nextVal);
|
int count = enums[i]->constValue->AsUInt32(&nextVal);
|
||||||
Assert(count == 1);
|
AssertPos(enums[i]->pos, count == 1);
|
||||||
++nextVal;
|
++nextVal;
|
||||||
|
|
||||||
/* When the source file as being parsed, the ConstExpr for any
|
/* When the source file as being parsed, the ConstExpr for any
|
||||||
@@ -2202,7 +2202,7 @@ lFinalizeEnumeratorSymbols(std::vector<Symbol *> &enums,
|
|||||||
enums[i]->pos);
|
enums[i]->pos);
|
||||||
castExpr = Optimize(castExpr);
|
castExpr = Optimize(castExpr);
|
||||||
enums[i]->constValue = dynamic_cast<ConstExpr *>(castExpr);
|
enums[i]->constValue = dynamic_cast<ConstExpr *>(castExpr);
|
||||||
Assert(enums[i]->constValue != NULL);
|
AssertPos(enums[i]->pos, enums[i]->constValue != NULL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
enums[i]->constValue = new ConstExpr(enumType, nextVal++,
|
enums[i]->constValue = new ConstExpr(enumType, nextVal++,
|
||||||
|
|||||||
60
stmt.cpp
60
stmt.cpp
@@ -140,7 +140,7 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
|
|
||||||
for (unsigned int i = 0; i < vars.size(); ++i) {
|
for (unsigned int i = 0; i < vars.size(); ++i) {
|
||||||
Symbol *sym = vars[i].sym;
|
Symbol *sym = vars[i].sym;
|
||||||
Assert(sym != NULL);
|
AssertPos(pos, sym != NULL);
|
||||||
if (sym->type == NULL)
|
if (sym->type == NULL)
|
||||||
continue;
|
continue;
|
||||||
Expr *initExpr = vars[i].init;
|
Expr *initExpr = vars[i].init;
|
||||||
@@ -191,7 +191,7 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
|
|
||||||
llvm::Type *llvmType = sym->type->LLVMType(g->ctx);
|
llvm::Type *llvmType = sym->type->LLVMType(g->ctx);
|
||||||
if (llvmType == NULL) {
|
if (llvmType == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(pos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,12 +478,12 @@ IfStmt::emitMaskedTrueAndFalse(FunctionEmitContext *ctx, llvm::Value *oldMask,
|
|||||||
lEmitIfStatements(ctx, trueStmts, "if: expr mixed, true statements");
|
lEmitIfStatements(ctx, trueStmts, "if: expr mixed, true statements");
|
||||||
// under varying control flow,, returns can't stop instruction
|
// under varying control flow,, returns can't stop instruction
|
||||||
// emission, so this better be non-NULL...
|
// emission, so this better be non-NULL...
|
||||||
Assert(ctx->GetCurrentBasicBlock());
|
AssertPos(ctx->GetDebugPos(), ctx->GetCurrentBasicBlock());
|
||||||
}
|
}
|
||||||
if (falseStmts) {
|
if (falseStmts) {
|
||||||
ctx->SetInternalMaskAndNot(oldMask, test);
|
ctx->SetInternalMaskAndNot(oldMask, test);
|
||||||
lEmitIfStatements(ctx, falseStmts, "if: expr mixed, false statements");
|
lEmitIfStatements(ctx, falseStmts, "if: expr mixed, false statements");
|
||||||
Assert(ctx->GetCurrentBasicBlock());
|
AssertPos(ctx->GetDebugPos(), ctx->GetCurrentBasicBlock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,7 +564,7 @@ IfStmt::emitVaryingIf(FunctionEmitContext *ctx, llvm::Value *ltest) const {
|
|||||||
(costIsAcceptable || g->opt.disableCoherentControlFlow)) {
|
(costIsAcceptable || g->opt.disableCoherentControlFlow)) {
|
||||||
ctx->StartVaryingIf(oldMask);
|
ctx->StartVaryingIf(oldMask);
|
||||||
emitMaskedTrueAndFalse(ctx, oldMask, ltest);
|
emitMaskedTrueAndFalse(ctx, oldMask, ltest);
|
||||||
Assert(ctx->GetCurrentBasicBlock());
|
AssertPos(pos, ctx->GetCurrentBasicBlock());
|
||||||
ctx->EndIf();
|
ctx->EndIf();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -587,7 +587,7 @@ IfStmt::emitMaskAllOn(FunctionEmitContext *ctx, llvm::Value *ltest,
|
|||||||
// compiler see what's going on so that subsequent optimizations for
|
// compiler see what's going on so that subsequent optimizations for
|
||||||
// code emitted here can operate with the knowledge that the mask is
|
// code emitted here can operate with the knowledge that the mask is
|
||||||
// definitely all on (until it modifies the mask itself).
|
// definitely all on (until it modifies the mask itself).
|
||||||
Assert(!g->opt.disableCoherentControlFlow);
|
AssertPos(pos, !g->opt.disableCoherentControlFlow);
|
||||||
if (!g->opt.disableMaskAllOnOptimizations)
|
if (!g->opt.disableMaskAllOnOptimizations)
|
||||||
ctx->SetInternalMask(LLVMMaskAllOn);
|
ctx->SetInternalMask(LLVMMaskAllOn);
|
||||||
llvm::Value *oldFunctionMask = ctx->GetFunctionMask();
|
llvm::Value *oldFunctionMask = ctx->GetFunctionMask();
|
||||||
@@ -637,7 +637,7 @@ IfStmt::emitMaskAllOn(FunctionEmitContext *ctx, llvm::Value *ltest,
|
|||||||
emitMaskedTrueAndFalse(ctx, LLVMMaskAllOn, ltest);
|
emitMaskedTrueAndFalse(ctx, LLVMMaskAllOn, ltest);
|
||||||
// In this case, return/break/continue isn't allowed to jump and end
|
// In this case, return/break/continue isn't allowed to jump and end
|
||||||
// emission.
|
// emission.
|
||||||
Assert(ctx->GetCurrentBasicBlock());
|
AssertPos(pos, ctx->GetCurrentBasicBlock());
|
||||||
ctx->EndIf();
|
ctx->EndIf();
|
||||||
ctx->BranchInst(bDone);
|
ctx->BranchInst(bDone);
|
||||||
|
|
||||||
@@ -666,7 +666,7 @@ IfStmt::emitMaskMixed(FunctionEmitContext *ctx, llvm::Value *oldMask,
|
|||||||
// Emit statements for true
|
// Emit statements for true
|
||||||
ctx->SetCurrentBasicBlock(bRunTrue);
|
ctx->SetCurrentBasicBlock(bRunTrue);
|
||||||
lEmitIfStatements(ctx, trueStmts, "if: expr mixed, true statements");
|
lEmitIfStatements(ctx, trueStmts, "if: expr mixed, true statements");
|
||||||
Assert(ctx->GetCurrentBasicBlock());
|
AssertPos(pos, ctx->GetCurrentBasicBlock());
|
||||||
ctx->BranchInst(bNext);
|
ctx->BranchInst(bNext);
|
||||||
ctx->SetCurrentBasicBlock(bNext);
|
ctx->SetCurrentBasicBlock(bNext);
|
||||||
}
|
}
|
||||||
@@ -683,7 +683,7 @@ IfStmt::emitMaskMixed(FunctionEmitContext *ctx, llvm::Value *oldMask,
|
|||||||
// Emit code for false
|
// Emit code for false
|
||||||
ctx->SetCurrentBasicBlock(bRunFalse);
|
ctx->SetCurrentBasicBlock(bRunFalse);
|
||||||
lEmitIfStatements(ctx, falseStmts, "if: expr mixed, false statements");
|
lEmitIfStatements(ctx, falseStmts, "if: expr mixed, false statements");
|
||||||
Assert(ctx->GetCurrentBasicBlock());
|
AssertPos(pos, ctx->GetCurrentBasicBlock());
|
||||||
ctx->BranchInst(bNext);
|
ctx->BranchInst(bNext);
|
||||||
ctx->SetCurrentBasicBlock(bNext);
|
ctx->SetCurrentBasicBlock(bNext);
|
||||||
}
|
}
|
||||||
@@ -837,7 +837,7 @@ void DoStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
ctx->SetFunctionMask(LLVMMaskAllOn);
|
ctx->SetFunctionMask(LLVMMaskAllOn);
|
||||||
if (bodyStmts)
|
if (bodyStmts)
|
||||||
bodyStmts->EmitCode(ctx);
|
bodyStmts->EmitCode(ctx);
|
||||||
Assert(ctx->GetCurrentBasicBlock());
|
AssertPos(pos, ctx->GetCurrentBasicBlock());
|
||||||
ctx->SetFunctionMask(oldFunctionMask);
|
ctx->SetFunctionMask(oldFunctionMask);
|
||||||
ctx->BranchInst(btest);
|
ctx->BranchInst(btest);
|
||||||
|
|
||||||
@@ -845,7 +845,7 @@ void DoStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
ctx->SetCurrentBasicBlock(bMixed);
|
ctx->SetCurrentBasicBlock(bMixed);
|
||||||
if (bodyStmts)
|
if (bodyStmts)
|
||||||
bodyStmts->EmitCode(ctx);
|
bodyStmts->EmitCode(ctx);
|
||||||
Assert(ctx->GetCurrentBasicBlock());
|
AssertPos(pos, ctx->GetCurrentBasicBlock());
|
||||||
ctx->BranchInst(btest);
|
ctx->BranchInst(btest);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -986,7 +986,7 @@ ForStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
// it and then jump into the loop test code. (Also start a new scope
|
// it and then jump into the loop test code. (Also start a new scope
|
||||||
// since the initiailizer may be a declaration statement).
|
// since the initiailizer may be a declaration statement).
|
||||||
if (init) {
|
if (init) {
|
||||||
Assert(dynamic_cast<StmtList *>(init) == NULL);
|
AssertPos(pos, dynamic_cast<StmtList *>(init) == NULL);
|
||||||
ctx->StartScope();
|
ctx->StartScope();
|
||||||
init->EmitCode(ctx);
|
init->EmitCode(ctx);
|
||||||
}
|
}
|
||||||
@@ -1015,7 +1015,7 @@ ForStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
if (doCoherentCheck)
|
if (doCoherentCheck)
|
||||||
Warning(test->pos, "Uniform condition supplied to cfor/cwhile "
|
Warning(test->pos, "Uniform condition supplied to cfor/cwhile "
|
||||||
"statement.");
|
"statement.");
|
||||||
Assert(ltest->getType() == LLVMTypes::BoolType);
|
AssertPos(pos, ltest->getType() == LLVMTypes::BoolType);
|
||||||
ctx->BranchInst(bloop, bexit, ltest);
|
ctx->BranchInst(bloop, bexit, ltest);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1051,7 +1051,7 @@ ForStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
ctx->SetFunctionMask(LLVMMaskAllOn);
|
ctx->SetFunctionMask(LLVMMaskAllOn);
|
||||||
if (stmts)
|
if (stmts)
|
||||||
stmts->EmitCode(ctx);
|
stmts->EmitCode(ctx);
|
||||||
Assert(ctx->GetCurrentBasicBlock());
|
AssertPos(pos, ctx->GetCurrentBasicBlock());
|
||||||
ctx->SetFunctionMask(oldFunctionMask);
|
ctx->SetFunctionMask(oldFunctionMask);
|
||||||
ctx->BranchInst(bstep);
|
ctx->BranchInst(bstep);
|
||||||
|
|
||||||
@@ -1364,8 +1364,8 @@ ForeachStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
ctx->SetFunctionMask(LLVMMaskAllOn);
|
ctx->SetFunctionMask(LLVMMaskAllOn);
|
||||||
|
|
||||||
// This should be caught during typechecking
|
// This should be caught during typechecking
|
||||||
Assert(startExprs.size() == dimVariables.size() &&
|
AssertPos(pos, startExprs.size() == dimVariables.size() &&
|
||||||
endExprs.size() == dimVariables.size());
|
endExprs.size() == dimVariables.size());
|
||||||
int nDims = (int)dimVariables.size();
|
int nDims = (int)dimVariables.size();
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
@@ -1704,7 +1704,7 @@ ForeachStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
ctx->SetContinueTarget(bbFullBodyContinue);
|
ctx->SetContinueTarget(bbFullBodyContinue);
|
||||||
ctx->AddInstrumentationPoint("foreach loop body (all on)");
|
ctx->AddInstrumentationPoint("foreach loop body (all on)");
|
||||||
stmts->EmitCode(ctx);
|
stmts->EmitCode(ctx);
|
||||||
Assert(ctx->GetCurrentBasicBlock() != NULL);
|
AssertPos(pos, ctx->GetCurrentBasicBlock() != NULL);
|
||||||
ctx->BranchInst(bbFullBodyContinue);
|
ctx->BranchInst(bbFullBodyContinue);
|
||||||
}
|
}
|
||||||
ctx->SetCurrentBasicBlock(bbFullBodyContinue); {
|
ctx->SetCurrentBasicBlock(bbFullBodyContinue); {
|
||||||
@@ -2094,7 +2094,7 @@ SwitchStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
|
|
||||||
const Type *type;
|
const Type *type;
|
||||||
if (expr == NULL || ((type = expr->GetType()) == NULL)) {
|
if (expr == NULL || ((type = expr->GetType()) == NULL)) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(pos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2112,7 +2112,7 @@ SwitchStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
|
|
||||||
llvm::Value *exprValue = expr->GetValue(ctx);
|
llvm::Value *exprValue = expr->GetValue(ctx);
|
||||||
if (exprValue == NULL) {
|
if (exprValue == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(pos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2342,7 +2342,7 @@ LabeledStmt::LabeledStmt(const char *n, Stmt *s, SourcePos p)
|
|||||||
void
|
void
|
||||||
LabeledStmt::EmitCode(FunctionEmitContext *ctx) const {
|
LabeledStmt::EmitCode(FunctionEmitContext *ctx) const {
|
||||||
llvm::BasicBlock *bblock = ctx->GetLabeledBasicBlock(name);
|
llvm::BasicBlock *bblock = ctx->GetLabeledBasicBlock(name);
|
||||||
Assert(bblock != NULL);
|
AssertPos(pos, bblock != NULL);
|
||||||
|
|
||||||
// End the current basic block with a jump to our basic block and then
|
// End the current basic block with a jump to our basic block and then
|
||||||
// set things up for emission to continue there. Note that the current
|
// set things up for emission to continue there. Note that the current
|
||||||
@@ -2597,7 +2597,7 @@ PrintStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
|
|
||||||
// Now we can emit code to call __do_print()
|
// Now we can emit code to call __do_print()
|
||||||
llvm::Function *printFunc = m->module->getFunction("__do_print");
|
llvm::Function *printFunc = m->module->getFunction("__do_print");
|
||||||
Assert(printFunc);
|
AssertPos(pos, printFunc);
|
||||||
|
|
||||||
llvm::Value *mask = ctx->GetFullMask();
|
llvm::Value *mask = ctx->GetFullMask();
|
||||||
// Set up the rest of the parameters to it
|
// Set up the rest of the parameters to it
|
||||||
@@ -2653,7 +2653,7 @@ AssertStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
llvm::Function *assertFunc =
|
llvm::Function *assertFunc =
|
||||||
isUniform ? m->module->getFunction("__do_assert_uniform") :
|
isUniform ? m->module->getFunction("__do_assert_uniform") :
|
||||||
m->module->getFunction("__do_assert_varying");
|
m->module->getFunction("__do_assert_varying");
|
||||||
Assert(assertFunc != NULL);
|
AssertPos(pos, assertFunc != NULL);
|
||||||
|
|
||||||
char *errorString;
|
char *errorString;
|
||||||
if (asprintf(&errorString, "%s:%d:%d: Assertion failed: %s\n",
|
if (asprintf(&errorString, "%s:%d:%d: Assertion failed: %s\n",
|
||||||
@@ -2721,18 +2721,18 @@ DeleteStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
|
|
||||||
const Type *exprType;
|
const Type *exprType;
|
||||||
if (expr == NULL || ((exprType = expr->GetType()) == NULL)) {
|
if (expr == NULL || ((exprType = expr->GetType()) == NULL)) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(pos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Value *exprValue = expr->GetValue(ctx);
|
llvm::Value *exprValue = expr->GetValue(ctx);
|
||||||
if (exprValue == NULL) {
|
if (exprValue == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(pos, m->errorCount > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Typechecking should catch this
|
// Typechecking should catch this
|
||||||
Assert(CastType<PointerType>(exprType) != NULL);
|
AssertPos(pos, CastType<PointerType>(exprType) != NULL);
|
||||||
|
|
||||||
if (exprType->IsUniformType()) {
|
if (exprType->IsUniformType()) {
|
||||||
// For deletion of a uniform pointer, we just need to cast the
|
// For deletion of a uniform pointer, we just need to cast the
|
||||||
@@ -2741,7 +2741,7 @@ DeleteStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
exprValue = ctx->BitCastInst(exprValue, LLVMTypes::VoidPointerType,
|
exprValue = ctx->BitCastInst(exprValue, LLVMTypes::VoidPointerType,
|
||||||
"ptr_to_void");
|
"ptr_to_void");
|
||||||
llvm::Function *func = m->module->getFunction("__delete_uniform");
|
llvm::Function *func = m->module->getFunction("__delete_uniform");
|
||||||
Assert(func != NULL);
|
AssertPos(pos, func != NULL);
|
||||||
|
|
||||||
ctx->CallInst(func, NULL, exprValue, "");
|
ctx->CallInst(func, NULL, exprValue, "");
|
||||||
}
|
}
|
||||||
@@ -2751,7 +2751,7 @@ DeleteStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
// only need to extend to 64-bit values on 32-bit targets before
|
// only need to extend to 64-bit values on 32-bit targets before
|
||||||
// calling it.
|
// calling it.
|
||||||
llvm::Function *func = m->module->getFunction("__delete_varying");
|
llvm::Function *func = m->module->getFunction("__delete_varying");
|
||||||
Assert(func != NULL);
|
AssertPos(pos, func != NULL);
|
||||||
if (g->target.is32Bit)
|
if (g->target.is32Bit)
|
||||||
exprValue = ctx->ZExtInst(exprValue, LLVMTypes::Int64VectorType,
|
exprValue = ctx->ZExtInst(exprValue, LLVMTypes::Int64VectorType,
|
||||||
"ptr_to_64");
|
"ptr_to_64");
|
||||||
@@ -2804,7 +2804,7 @@ DeleteStmt::EstimateCost() const {
|
|||||||
Stmt *
|
Stmt *
|
||||||
CreateForeachActiveStmt(Symbol *iterSym, Stmt *stmts, SourcePos pos) {
|
CreateForeachActiveStmt(Symbol *iterSym, Stmt *stmts, SourcePos pos) {
|
||||||
if (iterSym == NULL) {
|
if (iterSym == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
AssertPos(pos, m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2831,11 +2831,11 @@ CreateForeachActiveStmt(Symbol *iterSym, Stmt *stmts, SourcePos pos) {
|
|||||||
// First, call __movmsk(__mask)) to get the mask as a set of bits.
|
// First, call __movmsk(__mask)) to get the mask as a set of bits.
|
||||||
// This should be hoisted out of the loop
|
// This should be hoisted out of the loop
|
||||||
Symbol *maskSym = m->symbolTable->LookupVariable("__mask");
|
Symbol *maskSym = m->symbolTable->LookupVariable("__mask");
|
||||||
Assert(maskSym != NULL);
|
AssertPos(pos, maskSym != NULL);
|
||||||
Expr *maskVecExpr = new SymbolExpr(maskSym, pos);
|
Expr *maskVecExpr = new SymbolExpr(maskSym, pos);
|
||||||
std::vector<Symbol *> mmFuns;
|
std::vector<Symbol *> mmFuns;
|
||||||
m->symbolTable->LookupFunction("__movmsk", &mmFuns);
|
m->symbolTable->LookupFunction("__movmsk", &mmFuns);
|
||||||
Assert(mmFuns.size() == (g->target.maskBitCount == 32 ? 2 : 1));
|
AssertPos(pos, mmFuns.size() == (g->target.maskBitCount == 32 ? 2 : 1));
|
||||||
FunctionSymbolExpr *movmskFunc = new FunctionSymbolExpr("__movmsk", mmFuns,
|
FunctionSymbolExpr *movmskFunc = new FunctionSymbolExpr("__movmsk", mmFuns,
|
||||||
pos);
|
pos);
|
||||||
ExprList *movmskArgs = new ExprList(maskVecExpr, pos);
|
ExprList *movmskArgs = new ExprList(maskVecExpr, pos);
|
||||||
|
|||||||
29
util.cpp
29
util.cpp
@@ -420,18 +420,41 @@ PerformanceWarning(SourcePos p, const char *fmt, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
FatalError(const char *file, int line, const char *message) {
|
lPrintBugText() {
|
||||||
fprintf(stderr, "%s(%d): FATAL ERROR: %s\n", file, line, message);
|
|
||||||
fprintf(stderr, "***\n"
|
fprintf(stderr, "***\n"
|
||||||
"*** Please file a bug report at https://github.com/ispc/ispc/issues\n"
|
"*** Please file a bug report at https://github.com/ispc/ispc/issues\n"
|
||||||
"*** (Including as much information as you can about how to "
|
"*** (Including as much information as you can about how to "
|
||||||
"reproduce this error).\n"
|
"reproduce this error).\n"
|
||||||
"*** You have apparently encountered a bug in the compiler that we'd "
|
"*** You have apparently encountered a bug in the compiler that we'd "
|
||||||
"like to fix!\n***\n");
|
"like to fix!\n***\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
FatalError(const char *file, int line, const char *message) {
|
||||||
|
fprintf(stderr, "%s(%d): FATAL ERROR: %s\n", file, line, message);
|
||||||
|
lPrintBugText();
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DoAssert(const char *file, int line, const char *expr) {
|
||||||
|
fprintf(stderr, "%s:%u: Assertion failed: \"%s\".\n", file, line, expr);
|
||||||
|
lPrintBugText();
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DoAssertPos(SourcePos pos, const char *file, int line, const char *expr) {
|
||||||
|
Error(pos, "Assertion failed (%s:%u): \"%s\".", file, line, expr);
|
||||||
|
lPrintBugText();
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// http://en.wikipedia.org/wiki/Levenshtein_distance
|
// http://en.wikipedia.org/wiki/Levenshtein_distance
|
||||||
|
|||||||
Reference in New Issue
Block a user