Code beautification, no functional changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6459 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Misha Brukman 2003-05-31 06:22:37 +00:00
parent 162421522b
commit b3fabe0c83
2 changed files with 386 additions and 410 deletions

View File

@ -118,13 +118,11 @@ public:
if (isdigit(S[0]))
Result = "ll";
for (unsigned i = 0; i < S.size(); ++i)
{
for (unsigned i = 0; i < S.size(); ++i) {
char C = S[i];
if (C == '_' || C == '.' || C == '$' || isalpha(C) || isdigit(C))
Result += C;
else
{
else {
Result += '_';
Result += char('0' + ((unsigned char)C >> 4));
Result += char('0' + (C & 0xF));
@ -190,8 +188,8 @@ public:
const TargetMachine& target) {
string S;
switch(CE->getOpcode()) {
case Instruction::GetElementPtr:
{ // generate a symbolic expression for the byte address
case Instruction::GetElementPtr: {
// generate a symbolic expression for the byte address
const Value* ptrVal = CE->getOperand(0);
std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end());
const TargetData &TD = target.getTargetData();
@ -355,20 +353,15 @@ SparcFunctionAsmPrinter::printOperands(const MachineInstr *MI,
{
const MachineOperand& mop = MI->getOperand(opNum);
if (OpIsBranchTargetLabel(MI, opNum))
{
if (OpIsBranchTargetLabel(MI, opNum)) {
PrintOp1PlusOp2(mop, MI->getOperand(opNum+1), MI->getOpCode());
return 2;
}
else if (OpIsMemoryAddressBase(MI, opNum))
{
} else if (OpIsMemoryAddressBase(MI, opNum)) {
toAsm << "[";
PrintOp1PlusOp2(mop, MI->getOperand(opNum+1), MI->getOpCode());
toAsm << "]";
return 2;
}
else
{
} else {
printOneOperand(mop, MI->getOpCode());
return 1;
}
@ -395,8 +388,7 @@ SparcFunctionAsmPrinter::printOneOperand(const MachineOperand &mop,
{
case MachineOperand::MO_VirtualRegister:
case MachineOperand::MO_CCRegister:
case MachineOperand::MO_MachineRegister:
{
case MachineOperand::MO_MachineRegister: {
int regNum = (int)mop.getAllocatedRegNum();
if (regNum == Target.getRegInfo().getInvalidRegNum()) {
@ -408,8 +400,7 @@ SparcFunctionAsmPrinter::printOneOperand(const MachineOperand &mop,
break;
}
case MachineOperand::MO_PCRelativeDisp:
{
case MachineOperand::MO_PCRelativeDisp: {
const Value *Val = mop.getVRegValue();
assert(Val && "\tNULL Value in SparcFunctionAsmPrinter");
@ -450,7 +441,7 @@ SparcFunctionAsmPrinter::emitMachineInst(const MachineInstr *MI)
unsigned Opcode = MI->getOpCode();
if (Target.getInstrInfo().isDummyPhiInstr(Opcode))
return; // IGNORE PHI NODES
return; // Ignore Phi nodes
toAsm << "\t" << Target.getInstrInfo().getName(Opcode) << "\t";
@ -667,8 +658,7 @@ TypeToSize(const Type* type, const TargetMachine& target)
inline unsigned int
ConstantToSize(const Constant* CV, const TargetMachine& target)
{
if (const ConstantArray* CVA = dyn_cast<ConstantArray>(CV))
{
if (const ConstantArray* CVA = dyn_cast<ConstantArray>(CV)) {
const ArrayType *aty = cast<ArrayType>(CVA->getType());
if (ArrayTypeIsString(aty))
return 1 + CVA->getNumOperands();
@ -727,8 +717,7 @@ SparcModuleAsmPrinter::printSingleConstantValue(const Constant* CV)
toAsm << "\t" << TypeToDataDirective(CV->getType()) << "\t";
if (CV->getType()->isPrimitiveType())
{
if (CV->getType()->isPrimitiveType()) {
if (CV->getType()->isFloatingPoint()) {
// FP Constants are printed as integer constants to avoid losing
// precision...
@ -749,22 +738,17 @@ SparcModuleAsmPrinter::printSingleConstantValue(const Constant* CV)
} else {
WriteAsOperand(toAsm, CV, false, false) << "\n";
}
}
else if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(CV))
{ // This is a constant address for a global variable or method.
} else if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(CV)) {
// This is a constant address for a global variable or method.
// Use the name of the variable or method as the address value.
toAsm << getID(CPR->getValue()) << "\n";
}
else if (isa<ConstantPointerNull>(CV))
{ // Null pointer value
} else if (isa<ConstantPointerNull>(CV)) {
// Null pointer value
toAsm << "0\n";
}
else if (const ConstantExpr* CE = dyn_cast<ConstantExpr>(CV))
{ // Constant expression built from operators, constants, and symbolic addrs
} else if (const ConstantExpr* CE = dyn_cast<ConstantExpr>(CV)) {
// Constant expression built from operators, constants, and symbolic addrs
toAsm << ConstantExprToString(CE, Target) << "\n";
}
else
{
} else {
assert(0 && "Unknown elementary type for constant");
}
}
@ -775,8 +759,7 @@ SparcModuleAsmPrinter::PrintZeroBytesToPad(int numBytes)
for ( ; numBytes >= 8; numBytes -= 8)
printSingleConstantValue(Constant::getNullValue(Type::ULongTy));
if (numBytes >= 4)
{
if (numBytes >= 4) {
printSingleConstantValue(Constant::getNullValue(Type::UIntTy));
numBytes -= 4;
}
@ -793,24 +776,21 @@ SparcModuleAsmPrinter::printConstantValueOnly(const Constant* CV,
{
const ConstantArray *CVA = dyn_cast<ConstantArray>(CV);
if (CVA && isStringCompatible(CVA))
{ // print the string alone and return
if (CVA && isStringCompatible(CVA)) {
// print the string alone and return
toAsm << "\t" << ".ascii" << "\t" << getAsCString(CVA) << "\n";
}
else if (CVA)
{ // Not a string. Print the values in successive locations
} else if (CVA) {
// Not a string. Print the values in successive locations
const std::vector<Use> &constValues = CVA->getValues();
for (unsigned i=0; i < constValues.size(); i++)
printConstantValueOnly(cast<Constant>(constValues[i].get()));
}
else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV))
{ // Print the fields in successive locations. Pad to align if needed!
} else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) {
// Print the fields in successive locations. Pad to align if needed!
const StructLayout *cvsLayout =
Target.getTargetData().getStructLayout(CVS->getType());
const std::vector<Use>& constValues = CVS->getValues();
unsigned sizeSoFar = 0;
for (unsigned i=0, N = constValues.size(); i < N; i++)
{
for (unsigned i=0, N = constValues.size(); i < N; i++) {
const Constant* field = cast<Constant>(constValues[i].get());
// Check if padding is needed and insert one or more 0s.
@ -826,8 +806,7 @@ SparcModuleAsmPrinter::printConstantValueOnly(const Constant* CV,
}
assert(sizeSoFar == cvsLayout->StructSize &&
"Layout of constant struct may be incorrect!");
}
else
} else
printSingleConstantValue(CV);
if (numPadBytesAfter)
@ -847,8 +826,8 @@ SparcModuleAsmPrinter::printConstant(const Constant* CV, string valID)
// Print .size and .type only if it is not a string.
const ConstantArray *CVA = dyn_cast<ConstantArray>(CV);
if (CVA && isStringCompatible(CVA))
{ // print it as a string and return
if (CVA && isStringCompatible(CVA)) {
// print it as a string and return
toAsm << valID << ":\n";
toAsm << "\t" << ".ascii" << "\t" << getAsCString(CVA) << "\n";
return;

View File

@ -1445,8 +1445,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
// Let's check for chain rules outside the switch so that we don't have
// to duplicate the list of chain rule production numbers here again
//
if (ThisIsAChainRule(ruleForNode))
{
if (ThisIsAChainRule(ruleForNode)) {
// Chain rules have a single nonterminal on the RHS.
// Get the rule that matches the RHS non-terminal and use that instead.
//
@ -1455,9 +1454,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
nextRule = burm_rule(subtreeRoot->state, nts[0]);
nts = burm_nts[nextRule];
GetInstructionsByRule(subtreeRoot, nextRule, nts, target, mvec);
}
else
{
} else {
switch(ruleForNode) {
case 1: // stmt: Ret
case 2: // stmt: RetValue(reg)