diff options
author | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2008-05-14 11:31:39 +0000 |
---|---|---|
committer | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2008-05-14 11:31:39 +0000 |
commit | 2010b3eea608c420337a94b18899e9e378913edb (patch) | |
tree | bf88751f0f674e8c9193faf44ae20931d5d53448 | |
parent | 6422e8aa1ca15e85302e601397d5d1fae7410ed4 (diff) |
Detabification. Fixed indentation and spacing.
Changed cout to DOUT, and TODOs to FIXMEs.
Other changes as per coding conventions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51105 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/PIC16/PIC16.td | 2 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16AsmPrinter.cpp | 258 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16CallingConv.td | 3 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16ConstantPoolValue.h | 14 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16ISelDAGToDAG.cpp | 60 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16ISelLowering.cpp | 617 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16ISelLowering.h | 20 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16InstrFormats.td | 20 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16InstrInfo.cpp | 8 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16InstrInfo.td | 76 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16RegisterInfo.cpp | 27 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16RegisterInfo.h | 4 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16Subtarget.cpp | 4 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16Subtarget.h | 4 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16TargetMachine.cpp | 12 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16TargetMachine.h | 2 |
16 files changed, 525 insertions, 606 deletions
diff --git a/lib/Target/PIC16/PIC16.td b/lib/Target/PIC16/PIC16.td index 0ab4a3444f..8355de1067 100644 --- a/lib/Target/PIC16/PIC16.td +++ b/lib/Target/PIC16/PIC16.td @@ -32,7 +32,7 @@ def PIC16InstrInfo : InstrInfo { // Not currently supported, but work as SubtargetFeature placeholder. def FeaturePIC16Old : SubtargetFeature<"pic16old", "IsPIC16Old", "true", - "PIC16 Old ISA Support">; + "PIC16 Old ISA Support">; //===----------------------------------------------------------------------===// // PIC16 processors supported. diff --git a/lib/Target/PIC16/PIC16AsmPrinter.cpp b/lib/Target/PIC16/PIC16AsmPrinter.cpp index 151fafc4c5..f211face12 100644 --- a/lib/Target/PIC16/PIC16AsmPrinter.cpp +++ b/lib/Target/PIC16/PIC16AsmPrinter.cpp @@ -95,11 +95,11 @@ namespace { public: void SwitchToTextSection(const char *NewSection, - const GlobalValue *GV = NULL); + const GlobalValue *GV = NULL); void SwitchToDataSection(const char *NewSection, - const GlobalValue *GV = NULL); + const GlobalValue *GV = NULL); void SwitchToDataOvrSection(const char *NewSection, - const GlobalValue *GV = NULL); + const GlobalValue *GV = NULL); }; } // end of anonymous namespace @@ -117,7 +117,7 @@ FunctionPass *llvm::createPIC16CodePrinterPass(std::ostream &o, void PIC16AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const { - // Currently unimplemented. + // FIXME: Currently unimplemented. } @@ -137,77 +137,70 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) } else if (ACPV->isStub()) { FnStubs.insert(Name); O << TAI->getPrivateGlobalPrefix() << Name << "$stub"; - } else + } else { O << Name; - if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")"; + } - if (ACPV->getPCAdjustment() != 0) { - O << "-(" << TAI->getPrivateGlobalPrefix() << "PC" - << utostr(ACPV->getLabelId()) - << "+" << (unsigned)ACPV->getPCAdjustment(); + if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")"; - if (ACPV->mustAddCurrentAddress()) - O << "-."; + if (ACPV->getPCAdjustment() != 0) { + O << "-(" << TAI->getPrivateGlobalPrefix() << "PC" + << utostr(ACPV->getLabelId()) + << "+" << (unsigned)ACPV->getPCAdjustment(); - O << ")"; - } - O << "\n"; + if (ACPV->mustAddCurrentAddress()) + O << "-."; + + O << ")"; + } + O << "\n"; - // If the constant pool value is a extern weak symbol, remember to emit - // the weak reference. - if (GV && GV->hasExternalWeakLinkage()) - ExtWeakSymbols.insert(GV); + // If the constant pool value is a extern weak symbol, remember to emit + // the weak reference. + if (GV && GV->hasExternalWeakLinkage()) + ExtWeakSymbols.insert(GV); } -/// Emit the directives used by ASM on the start of functions -void PIC16AsmPrinter:: emitFunctionStart(MachineFunction &MF) +/// emitFunctionStart - Emit the directives used by ASM on the start of +/// functions. +void PIC16AsmPrinter::emitFunctionStart(MachineFunction &MF) { - // Print out the label for the function. - const Function *F = MF.getFunction(); - MachineFrameInfo *FrameInfo = MF.getFrameInfo(); - if (FrameInfo->hasStackObjects()) { - int indexBegin = FrameInfo->getObjectIndexBegin(); - int indexEnd = FrameInfo->getObjectIndexEnd(); - while (indexBegin<indexEnd) { - if (indexBegin ==0) - SwitchToDataOvrSection(F->getParent()->getModuleIdentifier().c_str(), - F); - - O << "\t\t" << CurrentFnName << "_" << indexBegin << " " << "RES" - << " " << FrameInfo->getObjectSize(indexBegin) << "\n" ; - indexBegin++; - } - } - SwitchToTextSection(CurrentFnName.c_str(), F); - O << "_" << CurrentFnName << ":" ; - O << "\n"; + // Print out the label for the function. + const Function *F = MF.getFunction(); + MachineFrameInfo *FrameInfo = MF.getFrameInfo(); + if (FrameInfo->hasStackObjects()) { + int indexBegin = FrameInfo->getObjectIndexBegin(); + int indexEnd = FrameInfo->getObjectIndexEnd(); + while (indexBegin < indexEnd) { + if (indexBegin == 0) + SwitchToDataOvrSection(F->getParent()->getModuleIdentifier().c_str(), + F); + + O << "\t\t" << CurrentFnName << "_" << indexBegin << " " << "RES" + << " " << FrameInfo->getObjectSize(indexBegin) << "\n" ; + indexBegin++; + } + } + SwitchToTextSection(CurrentFnName.c_str(), F); + O << "_" << CurrentFnName << ":" ; + O << "\n"; } /// runOnMachineFunction - This uses the printInstruction() /// method to print assembly for each instruction. /// -bool PIC16AsmPrinter:: -runOnMachineFunction(MachineFunction &MF) +bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) { - - // DW.SetModuleInfo(&getAnalysis<MachineModuleInfo>()); SetupMachineFunction(MF); O << "\n"; - // NOTE: we don't print out constant pools here, they are handled as - // instructions. - O << "\n"; - // What's my mangled name? CurrentFnName = Mang->getValueName(MF.getFunction()); // Emit the function start directives emitFunctionStart(MF); - // Emit pre-function debug information. - // DW.BeginFunction(&MF); - // Print out code for the function. for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { @@ -225,9 +218,6 @@ runOnMachineFunction(MachineFunction &MF) } } - // Emit post-function debug information. - // DW.EndFunction(); - // We didn't modify anything. return false; } @@ -238,61 +228,50 @@ printOperand(const MachineInstr *MI, int opNum, const char *Modifier) const MachineOperand &MO = MI->getOperand(opNum); const TargetRegisterInfo &RI = *TM.getRegisterInfo(); - switch (MO.getType()) - { + switch (MO.getType()) { case MachineOperand::MO_Register: - { if (TargetRegisterInfo::isPhysicalRegister(MO.getReg())) O << RI.get(MO.getReg()).Name; else assert(0 && "not implemented"); break; - } + case MachineOperand::MO_Immediate: - { if (!Modifier || strcmp(Modifier, "no_hash") != 0) O << "#"; O << (int)MO.getImm(); break; - } + case MachineOperand::MO_MachineBasicBlock: - { printBasicBlockLabel(MO.getMBB()); return; - } + case MachineOperand::MO_GlobalAddress: - { O << Mang->getValueName(MO.getGlobal())<<'+'<<MO.getOffset(); break; - } + case MachineOperand::MO_ExternalSymbol: - { O << MO.getSymbolName(); break; - } + case MachineOperand::MO_ConstantPoolIndex: - { O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_' << MO.getIndex(); break; - } + case MachineOperand::MO_FrameIndex: - { O << "_" << CurrentFnName << '+' << MO.getIndex(); break; - } + case MachineOperand::MO_JumpTableIndex: - { O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_' << MO.getIndex(); break; - } + default: - { O << "<unknown operand type>"; abort (); break; - } } // end switch. } @@ -300,15 +279,13 @@ static void printSOImm(std::ostream &O, int64_t V, const TargetAsmInfo *TAI) { assert(V < (1 << 12) && "Not a valid so_imm value!"); - unsigned Imm = V; - O << Imm; + O << (unsigned) V; } -/// printSOImmOperand - SOImm is 4-bit rotate amount in bits 8-11 with 8-bit +/// printSOImmOperand - SOImm is 4-bit rotated amount in bits 8-11 with 8-bit /// immediate in bits 0-7. -void PIC16AsmPrinter:: -printSOImmOperand(const MachineInstr *MI, int OpNum) +void PIC16AsmPrinter::printSOImmOperand(const MachineInstr *MI, int OpNum) { const MachineOperand &MO = MI->getOperand(OpNum); assert(MO.isImmediate() && "Not a valid so_imm value!"); @@ -316,7 +293,7 @@ printSOImmOperand(const MachineInstr *MI, int OpNum) } -void PIC16AsmPrinter:: printAddrModeOperand(const MachineInstr *MI, int Op) +void PIC16AsmPrinter::printAddrModeOperand(const MachineInstr *MI, int Op) { const MachineOperand &MO1 = MI->getOperand(Op); const MachineOperand &MO2 = MI->getOperand(Op+1); @@ -326,15 +303,15 @@ void PIC16AsmPrinter:: printAddrModeOperand(const MachineInstr *MI, int Op) return; } - if (!MO1.isRegister()) { // FIXME: This is for CP entries, but isn't right. + if (!MO1.isRegister()) { + // FIXME: This is for CP entries, but isn't right. printOperand(MI, Op); return; } // If this is Stack Slot if (MO1.isRegister()) { - if(strcmp(TM.getRegisterInfo()->get(MO1.getReg()).Name, "SP")==0) - { + if (strcmp(TM.getRegisterInfo()->get(MO1.getReg()).Name, "SP") == 0) { O << CurrentFnName <<"_"<< MO2.getImm(); return; } @@ -350,7 +327,7 @@ void PIC16AsmPrinter:: printAddrModeOperand(const MachineInstr *MI, int Op) } -void PIC16AsmPrinter:: printRegisterList(const MachineInstr *MI, int opNum) +void PIC16AsmPrinter::printRegisterList(const MachineInstr *MI, int opNum) { O << "{"; for (unsigned i = opNum, e = MI->getNumOperands(); i != e; ++i) { @@ -391,16 +368,13 @@ printCPInstOperand(const MachineInstr *MI, int OpNo, const char *Modifier) } -bool PIC16AsmPrinter:: doInitialization(Module &M) +bool PIC16AsmPrinter::doInitialization(Module &M) { - // Emit initial debug information. - // DW.BeginModule(&M); - bool Result = AsmPrinter::doInitialization(M); return Result; } -bool PIC16AsmPrinter:: doFinalization(Module &M) +bool PIC16AsmPrinter::doFinalization(Module &M) { const TargetData *TD = TM.getTargetData(); @@ -415,8 +389,8 @@ bool PIC16AsmPrinter:: doFinalization(Module &M) std::string name = Mang->getValueName(I); Constant *C = I->getInitializer(); - const Type *Type = C->getType(); - unsigned Size = TD->getABITypeSize(Type); + const Type *Ty = C->getType(); + unsigned Size = TD->getABITypeSize(Ty); unsigned Align = TD->getPreferredAlignmentLog(I); const char *VisibilityDirective = NULL; @@ -443,7 +417,7 @@ bool PIC16AsmPrinter:: doFinalization(Module &M) I->hasLinkOnceLinkage())) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (!NoZerosInBSS && TAI->getBSSSection()) - SwitchToDataSection(M.getModuleIdentifier().c_str(), I); + SwitchToDataSection(M.getModuleIdentifier().c_str(), I); else SwitchToDataSection(TAI->getDataSection(), I); if (TAI->getLCOMMDirective() != NULL) { @@ -453,33 +427,29 @@ bool PIC16AsmPrinter:: doFinalization(Module &M) O << TAI->getCOMMDirective() << name << "," << Size; } else { if (I->hasInternalLinkage()) - O << "\t.local\t" << name << "\n"; + O << "\t.local\t" << name << "\n"; O << TAI->getCOMMDirective() <<"\t" << name << " " <<"RES"<< " " - << Size; + << Size; O << "\n\t\tGLOBAL" <<" "<< name; if (TAI->getCOMMDirectiveTakesAlignment()) - O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align); + O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align); } continue; } } - switch (I->getLinkage()) - { + switch (I->getLinkage()) { case GlobalValue::AppendingLinkage: - { // FIXME: appending linkage variables should go into a section of // their name or something. For now, just emit them as external. - // Fall through - } + // FALL THROUGH + case GlobalValue::ExternalLinkage: - { O << "\t.globl " << name << "\n"; // FALL THROUGH - } + case GlobalValue::InternalLinkage: - { if (I->isConstant()) { const ConstantArray *CVA = dyn_cast<ConstantArray>(C); if (TAI->getCStringSection() && CVA && CVA->isCString()) { @@ -488,12 +458,10 @@ bool PIC16AsmPrinter:: doFinalization(Module &M) } } break; - } + default: - { assert(0 && "Unknown linkage type!"); break; - } } // end switch. EmitAlignment(Align, I); @@ -517,53 +485,53 @@ bool PIC16AsmPrinter:: doFinalization(Module &M) void PIC16AsmPrinter:: SwitchToTextSection(const char *NewSection, const GlobalValue *GV) { - O << "\n"; - if (NewSection && *NewSection) { - std::string codeSection = "code_"; - codeSection += NewSection; - codeSection += " "; - codeSection += "CODE"; - AsmPrinter::SwitchToTextSection(codeSection.c_str(),GV); - } - else - AsmPrinter::SwitchToTextSection(NewSection,GV); + O << "\n"; + if (NewSection && *NewSection) { + std::string codeSection = "code_"; + codeSection += NewSection; + codeSection += " "; + codeSection += "CODE"; + AsmPrinter::SwitchToTextSection(codeSection.c_str(), GV); + } + else + AsmPrinter::SwitchToTextSection(NewSection, GV); } void PIC16AsmPrinter:: SwitchToDataSection(const char *NewSection, const GlobalValue *GV) { - //Need to append index for page - O << "\n"; - if (NewSection && *NewSection) { - std::string dataSection ="udata_"; - dataSection+=NewSection; - if (dataSection.substr(dataSection.length()-2).compare(".o") == 0) { - dataSection = dataSection.substr(0,dataSection.length()-2); - } - dataSection += " "; - dataSection += "UDATA"; - AsmPrinter::SwitchToDataSection(dataSection.c_str(),GV); - } - else - AsmPrinter::SwitchToDataSection(NewSection,GV); + // Need to append index for page. + O << "\n"; + if (NewSection && *NewSection) { + std::string dataSection = "udata_"; + dataSection += NewSection; + if (dataSection.substr(dataSection.length() - 2).compare(".o") == 0) { + dataSection = dataSection.substr(0, dataSection.length() - 2); + } + dataSection += " "; + dataSection += "UDATA"; + AsmPrinter::SwitchToDataSection(dataSection.c_str(), GV); + } + else + AsmPrinter::SwitchToDataSection(NewSection, GV); } void PIC16AsmPrinter:: SwitchToDataOvrSection(const char *NewSection, const GlobalValue *GV) { - O << "\n"; - if (NewSection && *NewSection) { - std::string dataSection = "frame_"; - dataSection += NewSection; - if (dataSection.substr(dataSection.length()-2).compare(".o") == 0) { - dataSection = dataSection.substr(0,dataSection.length()-2); - } - dataSection += "_"; - dataSection += CurrentFnName; - dataSection += " "; - dataSection += "UDATA_OVR"; - AsmPrinter::SwitchToDataSection(dataSection.c_str(),GV); - } - else - AsmPrinter::SwitchToDataSection(NewSection,GV); + O << "\n"; + if (NewSection && *NewSection) { + std::string dataSection = "frame_"; + dataSection += NewSection; + if (dataSection.substr(dataSection.length() - 2).compare(".o") == 0) { + dataSection = dataSection.substr(0, dataSection.length() - 2); + } + dataSection += "_"; + dataSection += CurrentFnName; + dataSection += " "; + dataSection += "UDATA_OVR"; + AsmPrinter::SwitchToDataSection(dataSection.c_str(), GV); + } + else + AsmPrinter::SwitchToDataSection(NewSection, GV); } diff --git a/lib/Target/PIC16/PIC16CallingConv.td b/lib/Target/PIC16/PIC16CallingConv.td index bcd5f7c83d..fb6c9a33ff 100644 --- a/lib/Target/PIC16/PIC16CallingConv.td +++ b/lib/Target/PIC16/PIC16CallingConv.td @@ -1,4 +1,4 @@ -//===- PIC16CallingConv.td - Calling Conventions Sparc -----*- tablegen -*-===// +//===- PIC16CallingConv.td - Calling Conventions PIC16 -----*- tablegen -*-===// // // The LLVM Compiler Infrastructure // @@ -14,4 +14,3 @@ //===----------------------------------------------------------------------===// // Return Value Calling Conventions //===----------------------------------------------------------------------===// - diff --git a/lib/Target/PIC16/PIC16ConstantPoolValue.h b/lib/Target/PIC16/PIC16ConstantPoolValue.h index 04d4a17e68..9b1b7174ec 100644 --- a/lib/Target/PIC16/PIC16ConstantPoolValue.h +++ b/lib/Target/PIC16/PIC16ConstantPoolValue.h @@ -41,15 +41,15 @@ class PIC16ConstantPoolValue : public MachineConstantPoolValue { public: PIC16ConstantPoolValue(GlobalValue *gv, unsigned id, - PIC16CP::PIC16CPKind Kind = PIC16CP::CPValue, - unsigned char PCAdj = 0, const char *Modifier = NULL, - bool AddCurrentAddress = false); + PIC16CP::PIC16CPKind Kind = PIC16CP::CPValue, + unsigned char PCAdj = 0, const char *Modifier = NULL, + bool AddCurrentAddress = false); PIC16ConstantPoolValue(const char *s, unsigned id, - PIC16CP::PIC16CPKind Kind = PIC16CP::CPValue, - unsigned char PCAdj = 0, const char *Modifier = NULL, - bool AddCurrentAddress = false); + PIC16CP::PIC16CPKind Kind = PIC16CP::CPValue, + unsigned char PCAdj = 0, const char *Modifier = NULL, + bool AddCurrentAddress = false); PIC16ConstantPoolValue(GlobalValue *GV, PIC16CP::PIC16CPKind Kind, - const char *Modifier); + const char *Modifier); GlobalValue *getGV() const { return GV; } diff --git a/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp b/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp index 07ebd99a78..512893b2e6 100644 --- a/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp +++ b/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp @@ -56,11 +56,6 @@ class VISIBILITY_HIDDEN PIC16DAGToDAGISel : public SelectionDAGISel { /// PIC16-specific SelectionDAG. PIC16TargetLowering PIC16Lowering; - /// Subtarget - Keep a pointer to the PIC16Subtarget around so that we can - /// make the right decision when generating code for different targets. - //TODO: add initialization on constructor - //const PIC16Subtarget *Subtarget; - public: PIC16DAGToDAGISel(PIC16TargetMachine &tm) : SelectionDAGISel(PIC16Lowering), @@ -75,18 +70,18 @@ public: private: // Include the pieces autogenerated from the target description. - #include "PIC16GenDAGISel.inc" +#include "PIC16GenDAGISel.inc" SDNode *Select(SDOperand N); // Select addressing mode. currently assume base + offset addr mode. bool SelectAM(SDOperand Op, SDOperand N, SDOperand &Base, SDOperand &Offset); bool SelectDirectAM(SDOperand Op, SDOperand N, SDOperand &Base, - SDOperand &Offset); + SDOperand &Offset); bool StoreInDirectAM(SDOperand Op, SDOperand N, SDOperand &fsr); bool LoadFSR(SDOperand Op, SDOperand N, SDOperand &Base, SDOperand &Offset); bool LoadNothing(SDOperand Op, SDOperand N, SDOperand &Base, - SDOperand &Offset); + SDOperand &Offset); // getI8Imm - Return a target constant with the specified // value, of type i8. @@ -95,9 +90,9 @@ private: } - #ifndef NDEBUG +#ifndef NDEBUG unsigned Indent; - #endif +#endif }; } @@ -108,17 +103,16 @@ void PIC16DAGToDAGISel::InstructionSelectBasicBlock(SelectionDAG &SD) { DEBUG(BB->dump()); // Codegen the basic block. - #ifndef NDEBUG + DOUT << "===== Instruction selection begins:\n"; +#ifndef NDEBUG Indent = 0; - #endif +#endif // Select target instructions for the DAG. SD.setRoot(SelectRoot(SD.getRoot())); - #ifndef NDEBUG DOUT << "===== Instruction selection ends:\n"; - #endif SD.RemoveDeadNodes(); @@ -135,7 +129,7 @@ SelectDirectAM (SDOperand Op, SDOperand N, SDOperand &Base, SDOperand &Offset) // if Address is FI, get the TargetFrameIndex. if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(N)) { - cout << "--------- its frame Index\n"; + DOUT << "--------- its frame Index\n"; Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); Offset = CurDAG->getTargetConstant(0, MVT::i32); return true; @@ -154,11 +148,11 @@ SelectDirectAM (SDOperand Op, SDOperand N, SDOperand &Base, SDOperand &Offset) Offset = CurDAG->getTargetConstant((unsigned char)GC->getValue(), MVT::i8); if ((GA = dyn_cast<GlobalAddressSDNode>(N.getOperand(0)))) { Base = CurDAG->getTargetGlobalAddress(GA->getGlobal(), MVT::i16, - GC->getValue()); + GC->getValue()); return true; } else if (FrameIndexSDNode *FIN - = dyn_cast<FrameIndexSDNode>(N.getOperand(0))) { + = dyn_cast<FrameIndexSDNode>(N.getOperand(0))) { Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); return true; } @@ -168,7 +162,7 @@ SelectDirectAM (SDOperand Op, SDOperand N, SDOperand &Base, SDOperand &Offset) } -//FIXME: must also account for preinc/predec/postinc/postdec +// FIXME: must also account for preinc/predec/postinc/postdec. bool PIC16DAGToDAGISel:: StoreInDirectAM (SDOperand Op, SDOperand N, SDOperand &fsr) { @@ -181,12 +175,12 @@ StoreInDirectAM (SDOperand Op, SDOperand N, SDOperand &fsr) else if (isa<RegisterSDNode>(N.Val)) { //FIXME an attempt to retrieve the register number //but does not work - cout << "this is a register\n"; + DOUT << "this is a register\n"; Reg = dyn_cast<RegisterSDNode>(N.Val); fsr = CurDAG->getRegister(Reg->getReg(),MVT::i16); } else { - cout << "this is not a register\n"; + DOUT << "this is not a register\n"; // FIXME must use whatever load is using fsr = CurDAG->getRegister(1,MVT::i16); } @@ -204,7 +198,7 @@ LoadFSR (SDOperand Op, SDOperand N, SDOperand &Base, SDOperand &Offset) GA = dyn_cast<GlobalAddressSDNode>(N); Offset = CurDAG->getTargetConstant((unsigned char)GA->getOffset(), MVT::i8); Base = CurDAG->getTargetGlobalAddress(GA->getGlobal(), MVT::i16, - GA->getOffset()); + GA->getOffset()); return true; } else if (N.getOpcode() == PIC16ISD::Package) { @@ -215,17 +209,17 @@ LoadFSR (SDOperand Op, SDOperand N, SDOperand &Base, SDOperand &Offset) return false; } -//don't thake this seriously, it will change +// LoadNothing - Don't thake this seriously, it will change. bool PIC16DAGToDAGISel:: LoadNothing (SDOperand Op, SDOperand N, SDOperand &Base, SDOperand &Offset) { GlobalAddressSDNode *GA; if (N.getOpcode() == ISD::GlobalAddress) { GA = dyn_cast<GlobalAddressSDNode>(N); - cout << "==========" << GA->getOffset() << "\n"; + DOUT << "==========" << GA->getOffset() << "\n"; Offset = CurDAG->getTargetConstant((unsigned char)GA->getOffset(), MVT::i8); Base = CurDAG->getTargetGlobalAddress(GA->getGlobal(), MVT::i16, - GA->getOffset()); + GA->getOffset()); return true; } @@ -233,34 +227,34 @@ LoadNothing (SDOperand Op, SDOperand N, SDOperand &Base, SDOperand &Offset) } -/// Select instructions not customized! Used for -/// expanded, promoted and normal instructions +/// Select - Select instructions not customized! Used for +/// expanded, promoted and normal instructions. SDNode* PIC16DAGToDAGISel::Select(SDOperand N) { SDNode *Node = N.Val; unsigned Opcode = Node->getOpcode(); // Dump information about the Node being selected - #ifndef NDEBUG +#ifndef NDEBUG DOUT << std::string(Indent, ' ') << "Selecting: "; DEBUG(Node->dump(CurDAG)); DOUT << "\n"; Indent += 2; - #endif +#endif // If we have a custom node, we already have selected! if (Opcode >= ISD::BUILTIN_OP_END && Opcode < PIC16ISD::FIRST_NUMBER) { - #ifndef NDEBUG +#ifndef NDEBUG DOUT << std::string(Indent-2, ' ') << "== "; DEBUG(Node->dump(CurDAG)); DOUT << "\n"; Indent -= 2; - #endif +#endif return NULL; } /// - // Instruction Selection not handled by custom or by the + // FIXME: Instruction Selection not handled by custom or by the // auto-generated tablegen selection should be handled here. /// switch(Opcode) { @@ -270,7 +264,7 @@ SDNode* PIC16DAGToDAGISel::Select(SDOperand N) // Select the default instruction. SDNode *ResNode = SelectCode(N); - #ifndef NDEBUG +#ifndef NDEBUG DOUT << std::string(Indent-2, ' ') << "=> "; if (ResNode == NULL || ResNode == N.Val) DEBUG(N.Val->dump(CurDAG)); @@ -278,7 +272,7 @@ SDNode* PIC16DAGToDAGISel::Select(SDOperand N) DEBUG(ResNode->dump(CurDAG)); DOUT << "\n"; Indent -= 2; - #endif +#endif return ResNode; } diff --git a/lib/Target/PIC16/PIC16ISelLowering.cpp b/lib/Target/PIC16/PIC16ISelLowering.cpp index 45aaeda182..805efbb1f3 100644 --- a/lib/Target/PIC16/PIC16ISelLowering.cpp +++ b/lib/Target/PIC16/PIC16ISelLowering.cpp @@ -35,8 +35,7 @@ using namespace llvm; const char *PIC16TargetLowering:: getTargetNodeName(unsigned Opcode) const { - switch (Opcode) - { + switch (Opcode) { case PIC16ISD::Hi : return "PIC16ISD::Hi"; case PIC16ISD::Lo : return "PIC16ISD::Lo"; case PIC16ISD::Package : return "PIC16ISD::Package"; @@ -44,7 +43,7 @@ const char *PIC16TargetLowering:: getTargetNodeName(unsigned Opcode) const case PIC16ISD::SetBank : return "PIC16ISD::SetBank"; case PIC16ISD::SetPage : return "PIC16ISD::SetPage"; case PIC16ISD::Branch : return "PIC16ISD::Branch"; - case PIC16ISD::Cmp : return "PIC16ISD::Cmp"; + case PIC16ISD::Cmp : return "PIC16ISD::Cmp"; case PIC16ISD::BTFSS : return "PIC16ISD::BTFSS"; case PIC16ISD::BTFSC : return "PIC16ISD::BTFSC"; case PIC16ISD::XORCC : return "PIC16ISD::XORCC"; @@ -56,97 +55,77 @@ const char *PIC16TargetLowering:: getTargetNodeName(unsigned Opcode) const PIC16TargetLowering:: PIC16TargetLowering(PIC16TargetMachine &TM): TargetLowering(TM) { - // PIC16 does not have i1 type, so use i8 for - // setcc operations results (slt, sgt, ...). - // setSetCCResultType(MVT::i8); - // setSetCCResultContents(ZeroOrOneSetCCResult); - - // Set up the register classes - addRegisterClass(MVT::i8, PIC16::CPURegsRegisterClass); + // Set up the register classes. + addRegisterClass(MVT::i8, PIC16::CPURegsRegisterClass); addRegisterClass(MVT::i16, PIC16::PTRRegsRegisterClass); - // Custom - // Load extented operations for i1 types must be promoted - setLoadXAction(ISD::EXTLOAD, MVT::i1, Promote); + // Load extented operations for i1 types must be promoted . + setLoadXAction(ISD::EXTLOAD, MVT::i1, Promote); setLoadXAction(ISD::ZEXTLOAD, MVT::i1, Promote); setLoadXAction(ISD::SEXTLOAD, MVT::i1, Promote); - // Store operations for i1 types must be promoted - // setStoreXAction(MVT::i1, Promote); - // setStoreXAction(MVT::i8, Legal); - // setStoreXAction(MVT::i16, Custom); - // setStoreXAction(MVT::i32, Expand); - - // setOperationAction(ISD::BUILD_PAIR, MVT::i32, Expand); - // setOperationAction(ISD::BUILD_PAIR, MVT::i16, Expand); - - setOperationAction(ISD::ADD, MVT::i1, Promote); - setOperationAction(ISD::ADD, MVT::i8, Legal); - setOperationAction(ISD::ADD, MVT::i16, Custom); - setOperationAction(ISD::ADD, MVT::i32, Expand); - setOperationAction(ISD::ADD, MVT::i64, Expand); - - setOperationAction(ISD::SUB, MVT::i1, Promote); - setOperationAction(ISD::SUB, MVT::i8, Legal); - setOperationAction(ISD::SUB, MVT::i16, Custom); - setOperationAction(ISD::SUB, MVT::i32, Expand); - setOperationAction(ISD::SUB, MVT::i64, Expand); - - setOperationAction(ISD::ADDC, MVT::i1, Promote); - setOperationAction(ISD::ADDC, MVT::i8, Legal); - setOperationAction(ISD::ADDC, MVT::i16, Custom); - setOperationAction(ISD::ADDC, MVT::i32, Expand); - setOperationAction(ISD::ADDC, MVT::i64, Expand); - - setOperationAction(ISD::ADDE, MVT::i1, Promote); - setOperationAction(ISD::ADDE, MVT::i8, Legal); - setOperationAction(ISD::ADDE, MVT::i16, Custom); - setOperationAction(ISD::ADDE, MVT::i32, Expand); - setOperationAction(ISD::ADDE, MVT::i64, Expand); - - setOperationAction(ISD::SUBC, MVT::i1, Promote); - setOperationAction(ISD::SUBC, MVT::i8, Legal); - setOperationAction(ISD::SUBC, MVT::i16, Custom); - setOperationAction(ISD::SUBC, MVT::i32, Expand); - setOperationAction(ISD::SUBC, MVT::i64, Expand); - - setOperationAction(ISD::SUBE, MVT::i1, Promote); - setOperationAction(ISD::SUBE, MVT::i8, Legal); - setOperationAction(ISD::SUBE, MVT::i16, Custom); - setOperationAction(ISD::SUBE, MVT::i32, Expand); - setOperationAction(ISD::SUBE, MVT::i64, Expand); + setOperationAction(ISD::ADD, MVT::i1, Promote); + setOperationAction(ISD::ADD, MVT::i8, Legal); + setOperationAction(ISD::ADD, MVT::i16, Custom); + setOperationAction(ISD::ADD, MVT::i32, Expand); + setOperationAction(ISD::ADD, MVT::i64, Expand); + + setOperationAction(ISD::SUB, MVT::i1, Promote); + setOperationAction(ISD::SUB, MVT::i8, Legal); + setOperationAction(ISD::SUB, MVT::i16, Custom); + setOperationAction(ISD::SUB, MVT::i32, Expand); + setOperationAction(ISD::SUB, MVT::i64, Expand); + + setOperationAction(ISD::ADDC, MVT::i1, Promote); + setOperationAction(ISD::ADDC, MVT::i8, Legal); + setOperationAction(ISD::ADDC, MVT::i16, Custom); + setOperationAction(ISD::ADDC, MVT::i32, Expand); + setOperationAction(ISD::ADDC, MVT::i64, Expand); + + setOperationAction(ISD::ADDE, MVT::i1, Promote); + setOperationAction(ISD::ADDE, MVT::i8, Legal); + setOperationAction(ISD::ADDE, MVT::i16, Custom); + setOperationAction(ISD::ADDE, MVT::i32, Expand); + setOperationAction(ISD::ADDE, MVT::i64, Expand); + + setOperationAction(ISD::SUBC, MVT::i1, Promote); + setOperationAction(ISD::SUBC, MVT::i8, Legal); + setOperationAction(ISD::SUBC, MVT::i16, Custom); + setOperationAction(ISD::SUBC, MVT::i32, Expand); + setOperationAction(ISD::SUBC, MVT::i64, Expand); + + setOperationAction(ISD::SUBE, MVT::i1, Promote); |