minor tidying, no functionality change.

llvm-svn: 54099
This commit is contained in:
Chris Lattner 2008-07-26 20:15:14 +00:00
parent 944d306371
commit 6284378fcd
2 changed files with 15 additions and 31 deletions

View File

@ -1176,7 +1176,6 @@ Value *CodeGenFunction::EmitComplexToScalarConversion(ComplexPairTy Src,
Value *CodeGenFunction::EmitShuffleVector(Value* V1, Value *V2, ...) { Value *CodeGenFunction::EmitShuffleVector(Value* V1, Value *V2, ...) {
assert(V1->getType() == V2->getType() && assert(V1->getType() == V2->getType() &&
"Vector operands must be of the same type"); "Vector operands must be of the same type");
unsigned NumElements = unsigned NumElements =
cast<llvm::VectorType>(V1->getType())->getNumElements(); cast<llvm::VectorType>(V1->getType())->getNumElements();
@ -1184,13 +1183,10 @@ Value *CodeGenFunction::EmitShuffleVector(Value* V1, Value *V2, ...) {
va_start(va, V2); va_start(va, V2);
llvm::SmallVector<llvm::Constant*, 16> Args; llvm::SmallVector<llvm::Constant*, 16> Args;
for (unsigned i = 0; i < NumElements; i++) { for (unsigned i = 0; i < NumElements; i++) {
int n = va_arg(va, int); int n = va_arg(va, int);
assert(n >= 0 && n < (int)NumElements * 2 && assert(n >= 0 && n < (int)NumElements * 2 &&
"Vector shuffle index out of bounds!"); "Vector shuffle index out of bounds!");
Args.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, n)); Args.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, n));
} }
@ -1203,12 +1199,11 @@ Value *CodeGenFunction::EmitShuffleVector(Value* V1, Value *V2, ...) {
} }
llvm::Value *CodeGenFunction::EmitVector(llvm::Value * const *Vals, llvm::Value *CodeGenFunction::EmitVector(llvm::Value * const *Vals,
unsigned NumVals, bool isSplat) unsigned NumVals, bool isSplat) {
{
llvm::Value *Vec llvm::Value *Vec
= llvm::UndefValue::get(llvm::VectorType::get(Vals[0]->getType(), NumVals)); = llvm::UndefValue::get(llvm::VectorType::get(Vals[0]->getType(), NumVals));
for (unsigned i = 0, e = NumVals ; i != e; ++i) { for (unsigned i = 0, e = NumVals; i != e; ++i) {
llvm::Value *Val = isSplat ? Vals[0] : Vals[i]; llvm::Value *Val = isSplat ? Vals[0] : Vals[i];
llvm::Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, i); llvm::Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
Vec = Builder.CreateInsertElement(Vec, Val, Idx, "tmp"); Vec = Builder.CreateInsertElement(Vec, Val, Idx, "tmp");

View File

@ -87,12 +87,11 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
llvm::Value *AggLoc, bool isAggVol) { llvm::Value *AggLoc, bool isAggVol) {
// FIXME: handle vla's etc. // FIXME: handle vla's etc.
if (S.body_empty() || !isa<Expr>(S.body_back())) GetLast = false; if (S.body_empty() || !isa<Expr>(S.body_back())) GetLast = false;
CGDebugInfo *DI = CGM.getDebugInfo(); CGDebugInfo *DI = CGM.getDebugInfo();
if (DI) { if (DI) {
if (S.getLBracLoc().isValid()) { if (S.getLBracLoc().isValid())
DI->setLocation(S.getLBracLoc()); DI->setLocation(S.getLBracLoc());
}
DI->EmitRegionStart(CurFn, Builder); DI->EmitRegionStart(CurFn, Builder);
} }
@ -101,9 +100,8 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
EmitStmt(*I); EmitStmt(*I);
if (DI) { if (DI) {
if (S.getRBracLoc().isValid()) { if (S.getRBracLoc().isValid())
DI->setLocation(S.getRBracLoc()); DI->setLocation(S.getRBracLoc());
}
DI->EmitRegionEnd(CurFn, Builder); DI->EmitRegionEnd(CurFn, Builder);
} }
@ -169,9 +167,9 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
if (isDummyBlock(BB)) { if (isDummyBlock(BB)) {
BB->eraseFromParent(); BB->eraseFromParent();
Builder.SetInsertPoint(ThenBlock); Builder.SetInsertPoint(ThenBlock);
} } else {
else
Builder.CreateBr(ContBlock); Builder.CreateBr(ContBlock);
}
// Emit the 'else' code if present. // Emit the 'else' code if present.
if (const Stmt *Else = S.getElse()) { if (const Stmt *Else = S.getElse()) {
@ -181,9 +179,9 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
if (isDummyBlock(BB)) { if (isDummyBlock(BB)) {
BB->eraseFromParent(); BB->eraseFromParent();
Builder.SetInsertPoint(ElseBlock); Builder.SetInsertPoint(ElseBlock);
} } else {
else
Builder.CreateBr(ContBlock); Builder.CreateBr(ContBlock);
}
} }
// Emit the continuation block for code after the if. // Emit the continuation block for code after the if.
@ -376,11 +374,9 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
} else if (!hasAggregateLLVMType(RV->getType())) { } else if (!hasAggregateLLVMType(RV->getType())) {
RetValue = EmitScalarExpr(RV); RetValue = EmitScalarExpr(RV);
} else if (RV->getType()->isAnyComplexType()) { } else if (RV->getType()->isAnyComplexType()) {
llvm::Value *SRetPtr = CurFn->arg_begin(); EmitComplexExprIntoAddr(RV, CurFn->arg_begin(), false);
EmitComplexExprIntoAddr(RV, SRetPtr, false);
} else { } else {
llvm::Value *SRetPtr = CurFn->arg_begin(); EmitAggExpr(RV, CurFn->arg_begin(), false);
EmitAggExpr(RV, SRetPtr, false);
} }
if (RetValue) { if (RetValue) {
@ -542,14 +538,10 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
CaseRangeBlock = SavedCRBlock; CaseRangeBlock = SavedCRBlock;
} }
static inline std::string ConvertAsmString(const char *Start, static std::string ConvertAsmString(const char *Start, unsigned NumOperands,
unsigned NumOperands, bool IsSimple) {
bool IsSimple)
{
static unsigned AsmCounter = 0; static unsigned AsmCounter = 0;
AsmCounter++; AsmCounter++;
std::string Result; std::string Result;
if (IsSimple) { if (IsSimple) {
while (*Start) { while (*Start) {
@ -561,7 +553,6 @@ static inline std::string ConvertAsmString(const char *Start,
Result += "$$"; Result += "$$";
break; break;
} }
Start++; Start++;
} }
@ -588,14 +579,12 @@ static inline std::string ConvertAsmString(const char *Start,
if (EscapedChar == '%') { if (EscapedChar == '%') {
// Escaped percentage sign. // Escaped percentage sign.
Result += '%'; Result += '%';
} } else if (EscapedChar == '=') {
else if (EscapedChar == '=') {
// Generate an unique ID. // Generate an unique ID.
Result += llvm::utostr(AsmCounter); Result += llvm::utostr(AsmCounter);
} else if (isdigit(EscapedChar)) { } else if (isdigit(EscapedChar)) {
// %n - Assembler operand n // %n - Assembler operand n
char *End; char *End;
unsigned long n = strtoul(Start, &End, 10); unsigned long n = strtoul(Start, &End, 10);
if (Start == End) { if (Start == End) {
// FIXME: This should be caught during Sema. // FIXME: This should be caught during Sema.