Some Mips minor fixes

Added support for mips little endian arch => mipsel



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51923 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bruno Cardoso Lopes 2008-06-04 01:45:25 +00:00
parent 3094a4c97a
commit d2947ee33e
8 changed files with 48 additions and 15 deletions

View File

@ -547,5 +547,7 @@ doFinalization(Module &M)
} }
} }
O << "\n";
return AsmPrinter::doFinalization(M); return AsmPrinter::doFinalization(M);
} }

View File

@ -365,6 +365,7 @@ LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, unsigned CC)
Chain = DAG.getNode(MipsISD::JmpLink, NodeTys, &Ops[0], Ops.size()); Chain = DAG.getNode(MipsISD::JmpLink, NodeTys, &Ops[0], Ops.size());
InFlag = Chain.getValue(1); InFlag = Chain.getValue(1);
// Create the CALLSEQ_END node.
Chain = DAG.getCALLSEQ_END(Chain, Chain = DAG.getCALLSEQ_END(Chain,
DAG.getConstant(NumBytes, getPointerTy()), DAG.getConstant(NumBytes, getPointerTy()),
DAG.getConstant(0, getPointerTy()), DAG.getConstant(0, getPointerTy()),
@ -400,8 +401,6 @@ LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, unsigned CC)
InFlag = Chain.getValue(1); InFlag = Chain.getValue(1);
} }
// Create the CALLSEQ_END node.
// Handle result values, copying them out of physregs into vregs that we // Handle result values, copying them out of physregs into vregs that we
// return. // return.
return SDOperand(LowerCallResult(Chain, InFlag, Op.Val, CC, DAG), Op.ResNo); return SDOperand(LowerCallResult(Chain, InFlag, Op.Val, CC, DAG), Op.ResNo);

View File

@ -135,7 +135,6 @@ class ArithOverflowR<bits<6> op, bits<6> func, string instr_asm>:
[], IIAlu>; [], IIAlu>;
// Arithmetic 2 register operands // Arithmetic 2 register operands
let isCommutable = 1 in
class ArithI<bits<6> op, string instr_asm, SDNode OpNode, class ArithI<bits<6> op, string instr_asm, SDNode OpNode,
Operand Od, PatLeaf imm_type> : Operand Od, PatLeaf imm_type> :
FI< op, FI< op,

View File

@ -147,7 +147,7 @@ getReservedRegs(const MachineFunction &MF) const
// //
// 0 ---------- // 0 ----------
// 4 Args to pass // 4 Args to pass
// . saved $GP (used in PIC - not supported yet) // . saved $GP (used in PIC)
// . Local Area // . Local Area
// . saved "Callee Saved" Registers // . saved "Callee Saved" Registers
// . saved FP // . saved FP

View File

@ -17,8 +17,9 @@
using namespace llvm; using namespace llvm;
MipsSubtarget::MipsSubtarget(const TargetMachine &TM, const Module &M, MipsSubtarget::MipsSubtarget(const TargetMachine &TM, const Module &M,
const std::string &FS) : const std::string &FS, bool little) :
IsMipsIII(false) IsMipsIII(false),
IsLittle(little)
{ {
std::string CPU = "mips1"; std::string CPU = "mips1";

View File

@ -27,14 +27,14 @@ class MipsSubtarget : public TargetSubtarget {
protected: protected:
bool IsMipsIII; bool IsMipsIII;
bool IsLittle;
InstrItineraryData InstrItins; InstrItineraryData InstrItins;
public: public:
/// This constructor initializes the data members to match that /// This constructor initializes the data members to match that
/// of the specified module. /// of the specified module.
///
MipsSubtarget(const TargetMachine &TM, const Module &M, MipsSubtarget(const TargetMachine &TM, const Module &M,
const std::string &FS); const std::string &FS, bool little);
/// ParseSubtargetFeatures - Parses features string setting specified /// ParseSubtargetFeatures - Parses features string setting specified
/// subtarget options. Definition of function is auto generated by tblgen. /// subtarget options. Definition of function is auto generated by tblgen.
@ -43,6 +43,9 @@ public:
/// isMipsIII - Return true if the selected CPU supports MipsIII ISA /// isMipsIII - Return true if the selected CPU supports MipsIII ISA
/// support. /// support.
bool isMipsIII() const { return IsMipsIII; } bool isMipsIII() const { return IsMipsIII; }
/// isMipsIII - Return true if the target is little endian.
bool isLittle() const { return IsLittle; }
}; };
} // End llvm namespace } // End llvm namespace

View File

@ -21,6 +21,7 @@ using namespace llvm;
// Register the target. // Register the target.
static RegisterTarget<MipsTargetMachine> X("mips", " Mips"); static RegisterTarget<MipsTargetMachine> X("mips", " Mips");
static RegisterTarget<MipselTargetMachine> Y("mipsel", " Mipsel");
const TargetAsmInfo *MipsTargetMachine:: const TargetAsmInfo *MipsTargetMachine::
createTargetAsmInfo() const createTargetAsmInfo() const
@ -35,11 +36,13 @@ createTargetAsmInfo() const
// offset from the stack/frame pointer, so StackGrowsUp is used. // offset from the stack/frame pointer, so StackGrowsUp is used.
// When using CodeModel::Large the behaviour // When using CodeModel::Large the behaviour
// //
//
MipsTargetMachine:: MipsTargetMachine::
MipsTargetMachine(const Module &M, const std::string &FS): MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle=false):
Subtarget(*this, M, FS), DataLayout("E-p:32:32:32"), Subtarget(*this, M, FS, isLittle),
InstrInfo(*this), FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0), DataLayout(isLittle ? std::string("e-p:32:32:32") :
std::string("E-p:32:32:32")),
InstrInfo(*this),
FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0),
TLInfo(*this) TLInfo(*this)
{ {
if (getRelocationModel() != Reloc::Static) if (getRelocationModel() != Reloc::Static)
@ -48,6 +51,10 @@ MipsTargetMachine(const Module &M, const std::string &FS):
setCodeModel(CodeModel::Small); setCodeModel(CodeModel::Small);
} }
MipselTargetMachine::
MipselTargetMachine(const Module &M, const std::string &FS) :
MipsTargetMachine(M, FS, true) {}
// return 0 and must specify -march to gen MIPS code. // return 0 and must specify -march to gen MIPS code.
unsigned MipsTargetMachine:: unsigned MipsTargetMachine::
getModuleMatchQuality(const Module &M) getModuleMatchQuality(const Module &M)
@ -60,6 +67,18 @@ getModuleMatchQuality(const Module &M)
return 0; return 0;
} }
// return 0 and must specify -march to gen MIPSel code.
unsigned MipselTargetMachine::
getModuleMatchQuality(const Module &M)
{
// We strongly match "mipsel-*".
std::string TT = M.getTargetTriple();
if (TT.size() >= 7 && std::string(TT.begin(), TT.begin()+7) == "mipsel-")
return 20;
return 0;
}
// Install an instruction selector pass using // Install an instruction selector pass using
// the ISelDag to gen Mips code. // the ISelDag to gen Mips code.
bool MipsTargetMachine:: bool MipsTargetMachine::

View File

@ -33,7 +33,7 @@ namespace llvm {
virtual const TargetAsmInfo *createTargetAsmInfo() const; virtual const TargetAsmInfo *createTargetAsmInfo() const;
public: public:
MipsTargetMachine(const Module &M, const std::string &FS); MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle);
virtual const MipsInstrInfo *getInstrInfo() const virtual const MipsInstrInfo *getInstrInfo() const
{ return &InstrInfo; } { return &InstrInfo; }
@ -60,6 +60,16 @@ namespace llvm {
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast, virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
std::ostream &Out); std::ostream &Out);
}; };
/// MipselTargetMachine - Mipsel target machine.
///
class MipselTargetMachine : public MipsTargetMachine {
public:
MipselTargetMachine(const Module &M, const std::string &FS);
static unsigned getModuleMatchQuality(const Module &M);
};
} // End llvm namespace } // End llvm namespace
#endif #endif