mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-25 03:30:37 +00:00
than on MipsSubtargetInfo. This required a bit of massaging in the MC level to handle this since MC is a) largely a collection of disparate classes with no hierarchy, and b) there's no overarching equivalent to the TargetMachine, instead only the subtarget via MCSubtargetInfo (which is the base class of TargetSubtargetInfo). We're now storing the ABI in both the TargetMachine level and in the MC level because the AsmParser and the TargetStreamer both need to know what ABI we have to parse assembly and emit objects. The target streamer has a pointer to the one in the asm parser and is updated when the asm parser is created. This is fragile as the FIXME comment notes, but shouldn't be a problem in practice since we always create an asm parser before attempting to emit object code via the assembler. The TargetMachine now contains the ABI so that the DataLayout can be constructed dependent upon ABI. All testcases have been updated to use the -target-abi command line flag so that we can set the ABI without using a subtarget feature. Should be no change visible externally here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227102 91177308-0d34-0410-b5e6-96231b3b80d8
89 lines
2.9 KiB
C++
89 lines
2.9 KiB
C++
//===---- MipsABIInfo.cpp - Information about MIPS ABI's ------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "MipsABIInfo.h"
|
|
#include "MipsRegisterInfo.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
#include "llvm/MC/MCTargetOptions.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
static const MCPhysReg O32IntRegs[4] = {Mips::A0, Mips::A1, Mips::A2, Mips::A3};
|
|
|
|
static const MCPhysReg Mips64IntRegs[8] = {
|
|
Mips::A0_64, Mips::A1_64, Mips::A2_64, Mips::A3_64,
|
|
Mips::T0_64, Mips::T1_64, Mips::T2_64, Mips::T3_64};
|
|
}
|
|
|
|
const ArrayRef<MCPhysReg> MipsABIInfo::GetByValArgRegs() const {
|
|
if (IsO32())
|
|
return makeArrayRef(O32IntRegs);
|
|
if (IsN32() || IsN64())
|
|
return makeArrayRef(Mips64IntRegs);
|
|
llvm_unreachable("Unhandled ABI");
|
|
}
|
|
|
|
const ArrayRef<MCPhysReg> MipsABIInfo::GetVarArgRegs() const {
|
|
if (IsO32())
|
|
return makeArrayRef(O32IntRegs);
|
|
if (IsN32() || IsN64())
|
|
return makeArrayRef(Mips64IntRegs);
|
|
llvm_unreachable("Unhandled ABI");
|
|
}
|
|
|
|
unsigned MipsABIInfo::GetCalleeAllocdArgSizeInBytes(CallingConv::ID CC) const {
|
|
if (IsO32())
|
|
return CC != CallingConv::Fast ? 16 : 0;
|
|
if (IsN32() || IsN64() || IsEABI())
|
|
return 0;
|
|
llvm_unreachable("Unhandled ABI");
|
|
}
|
|
|
|
MipsABIInfo MipsABIInfo::computeTargetABI(Triple TT, StringRef CPU,
|
|
const MCTargetOptions &Options) {
|
|
if (Options.getABIName().startswith("o32"))
|
|
return MipsABIInfo::O32();
|
|
else if (Options.getABIName().startswith("n32"))
|
|
return MipsABIInfo::N32();
|
|
else if (Options.getABIName().startswith("n64"))
|
|
return MipsABIInfo::N64();
|
|
else if (Options.getABIName().startswith("eabi"))
|
|
return MipsABIInfo::EABI();
|
|
else if (!Options.getABIName().empty())
|
|
llvm_unreachable("Unknown ABI option for MIPS");
|
|
|
|
// FIXME: This shares code with the selectMipsCPU routine that's
|
|
// used and not shared in a couple of other places. This needs unifying
|
|
// at some level.
|
|
if (CPU.empty() || CPU == "generic") {
|
|
if (TT.getArch() == Triple::mips || TT.getArch() == Triple::mipsel)
|
|
CPU = "mips32";
|
|
else
|
|
CPU = "mips64";
|
|
}
|
|
|
|
return StringSwitch<MipsABIInfo>(CPU)
|
|
.Case("mips1", MipsABIInfo::O32())
|
|
.Case("mips2", MipsABIInfo::O32())
|
|
.Case("mips32", MipsABIInfo::O32())
|
|
.Case("mips32r2", MipsABIInfo::O32())
|
|
.Case("mips32r6", MipsABIInfo::O32())
|
|
.Case("mips16", MipsABIInfo::O32())
|
|
.Case("mips3", MipsABIInfo::N64())
|
|
.Case("mips4", MipsABIInfo::N64())
|
|
.Case("mips5", MipsABIInfo::N64())
|
|
.Case("mips64", MipsABIInfo::N64())
|
|
.Case("mips64r2", MipsABIInfo::N64())
|
|
.Case("mips64r6", MipsABIInfo::N64())
|
|
.Case("octeon", MipsABIInfo::N64())
|
|
.Default(MipsABIInfo::Unknown());
|
|
}
|