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