Modify SizeOf() and StructOffset() to not compute value based on target for generic targets.

Specifically, we want to be able to late-bind on whether the mask is i32s or i1s, so if there's
any chance of ambiguity, we emit code that does the "GEP from a NULL base pointer" trick to
compute the value later in compilation.
This commit is contained in:
Matt Pharr
2012-01-04 12:29:45 -08:00
parent 23b85cd88d
commit 4151778f5e
4 changed files with 62 additions and 11 deletions

View File

@@ -1106,7 +1106,8 @@ lEmitBinaryArith(BinaryExpr::Op op, llvm::Value *value0, llvm::Value *value1,
// points to in order to return the difference in elements.
LLVM_TYPE_CONST llvm::Type *llvmElementType =
ptrType->GetBaseType()->LLVMType(g->ctx);
llvm::Value *size = g->target.SizeOf(llvmElementType);
llvm::Value *size = g->target.SizeOf(llvmElementType,
ctx->GetCurrentBasicBlock());
if (ptrType->IsVaryingType())
size = ctx->SmearUniform(size);
@@ -5875,7 +5876,7 @@ SizeOfExpr::GetValue(FunctionEmitContext *ctx) const {
if (llvmType == NULL)
return NULL;
return g->target.SizeOf(llvmType);
return g->target.SizeOf(llvmType, ctx->GetCurrentBasicBlock());
}