Compare commits

...

1 Commits
main ... stakr

Author SHA1 Message Date
eeb7d94730 Add Stakr skeleton 2026-04-24 11:51:55 -04:00
33 changed files with 815 additions and 385 deletions

View File

@ -596,6 +596,7 @@ set(LLVM_ALL_EXPERIMENTAL_TARGETS
CSKY
DirectX
M68k
Stakr
Xtensa
)

View File

@ -83,6 +83,7 @@ public:
sparcv9, // Sparcv9: Sparcv9
sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
systemz, // SystemZ: s390x
stakr, // stakr
tce, // TCE (http://tce.cs.tut.fi/): tce
tcele, // TCE little endian (http://tce.cs.tut.fi/): tcele
thumb, // Thumb (little endian): thumb, thumbv.*
@ -383,9 +384,7 @@ public:
ObjectFormat == Other.ObjectFormat;
}
bool operator!=(const Triple &Other) const {
return !(*this == Other);
}
bool operator!=(const Triple &Other) const { return !(*this == Other); }
bool operator<(const Triple &Other) const {
return std::tie(Arch, SubArch, Vendor, OS, Environment, ObjectFormat,
@ -436,9 +435,7 @@ public:
OSType getOS() const { return OS; }
/// Does this triple have the optional environment (fourth) component?
bool hasEnvironment() const {
return getEnvironmentName() != "";
}
bool hasEnvironment() const { return getEnvironmentName() != ""; }
/// Get the parsed environment type of this triple.
EnvironmentType getEnvironment() const { return Environment; }
@ -602,23 +599,15 @@ public:
/// changes, i.e., if the two operating systems diverge or their version
/// numbers get out of sync, that will need to be changed.
/// watchOS has completely different version numbers so it is not included.
bool isiOS() const {
return getOS() == Triple::IOS || isTvOS();
}
bool isiOS() const { return getOS() == Triple::IOS || isTvOS(); }
/// Is this an Apple tvOS triple.
bool isTvOS() const {
return getOS() == Triple::TvOS;
}
bool isTvOS() const { return getOS() == Triple::TvOS; }
/// Is this an Apple watchOS triple.
bool isWatchOS() const {
return getOS() == Triple::WatchOS;
}
bool isWatchOS() const { return getOS() == Triple::WatchOS; }
bool isWatchABI() const {
return getSubArch() == Triple::ARMSubArch_v7k;
}
bool isWatchABI() const { return getSubArch() == Triple::ARMSubArch_v7k; }
/// Is this an Apple XROS triple.
bool isXROS() const { return getOS() == Triple::XROS; }
@ -664,31 +653,19 @@ public:
isMacCatalystEnvironment()));
}
bool isOSNetBSD() const {
return getOS() == Triple::NetBSD;
}
bool isOSNetBSD() const { return getOS() == Triple::NetBSD; }
bool isOSOpenBSD() const {
return getOS() == Triple::OpenBSD;
}
bool isOSOpenBSD() const { return getOS() == Triple::OpenBSD; }
bool isOSFreeBSD() const {
return getOS() == Triple::FreeBSD;
}
bool isOSFreeBSD() const { return getOS() == Triple::FreeBSD; }
bool isOSFuchsia() const {
return getOS() == Triple::Fuchsia;
}
bool isOSFuchsia() const { return getOS() == Triple::Fuchsia; }
bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
bool isOSSolaris() const {
return getOS() == Triple::Solaris;
}
bool isOSSolaris() const { return getOS() == Triple::Solaris; }
bool isOSIAMCU() const {
return getOS() == Triple::ELFIAMCU;
}
bool isOSIAMCU() const { return getOS() == Triple::ELFIAMCU; }
bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
@ -703,19 +680,13 @@ public:
}
/// Tests whether the OS is Haiku.
bool isOSHaiku() const {
return getOS() == Triple::Haiku;
}
bool isOSHaiku() const { return getOS() == Triple::Haiku; }
/// Tests whether the OS is UEFI.
bool isUEFI() const {
return getOS() == Triple::UEFI;
}
bool isUEFI() const { return getOS() == Triple::UEFI; }
/// Tests whether the OS is Windows.
bool isOSWindows() const {
return getOS() == Triple::Win32;
}
bool isOSWindows() const { return getOS() == Triple::Win32; }
/// Checks if the environment is MSVC.
bool isKnownWindowsMSVCEnvironment() const {
@ -762,19 +733,13 @@ public:
}
/// Tests whether the OS is Linux.
bool isOSLinux() const {
return getOS() == Triple::Linux;
}
bool isOSLinux() const { return getOS() == Triple::Linux; }
/// Tests whether the OS is kFreeBSD.
bool isOSKFreeBSD() const {
return getOS() == Triple::KFreeBSD;
}
bool isOSKFreeBSD() const { return getOS() == Triple::KFreeBSD; }
/// Tests whether the OS is Hurd.
bool isOSHurd() const {
return getOS() == Triple::Hurd;
}
bool isOSHurd() const { return getOS() == Triple::Hurd; }
/// Tests whether the OS is WASI.
bool isOSWASI() const {
@ -783,9 +748,7 @@ public:
}
/// Tests whether the OS is Emscripten.
bool isOSEmscripten() const {
return getOS() == Triple::Emscripten;
}
bool isOSEmscripten() const { return getOS() == Triple::Emscripten; }
/// Tests whether the OS uses glibc.
bool isOSGlibc() const {
@ -795,44 +758,30 @@ public:
}
/// Tests whether the OS is AIX.
bool isOSAIX() const {
return getOS() == Triple::AIX;
}
bool isOSAIX() const { return getOS() == Triple::AIX; }
bool isOSSerenity() const {
return getOS() == Triple::Serenity;
}
bool isOSSerenity() const { return getOS() == Triple::Serenity; }
/// Tests whether the OS is QURT.
bool isOSQurt() const { return getOS() == Triple::QURT; }
/// Tests whether the OS uses the ELF binary format.
bool isOSBinFormatELF() const {
return getObjectFormat() == Triple::ELF;
}
bool isOSBinFormatELF() const { return getObjectFormat() == Triple::ELF; }
/// Tests whether the OS uses the COFF binary format.
bool isOSBinFormatCOFF() const {
return getObjectFormat() == Triple::COFF;
}
bool isOSBinFormatCOFF() const { return getObjectFormat() == Triple::COFF; }
/// Tests whether the OS uses the GOFF binary format.
bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
/// Tests whether the environment is MachO.
bool isOSBinFormatMachO() const {
return getObjectFormat() == Triple::MachO;
}
bool isOSBinFormatMachO() const { return getObjectFormat() == Triple::MachO; }
/// Tests whether the OS uses the Wasm binary format.
bool isOSBinFormatWasm() const {
return getObjectFormat() == Triple::Wasm;
}
bool isOSBinFormatWasm() const { return getObjectFormat() == Triple::Wasm; }
/// Tests whether the OS uses the XCOFF binary format.
bool isOSBinFormatXCOFF() const {
return getObjectFormat() == Triple::XCOFF;
}
bool isOSBinFormatXCOFF() const { return getObjectFormat() == Triple::XCOFF; }
/// Tests whether the OS uses the DXContainer binary format.
bool isOSBinFormatDXContainer() const {
@ -847,16 +796,14 @@ public:
/// Tests whether the target is the PS4 platform.
bool isPS4() const {
return getArch() == Triple::x86_64 &&
getVendor() == Triple::SCEI &&
return getArch() == Triple::x86_64 && getVendor() == Triple::SCEI &&
getOS() == Triple::PS4;
}
/// Tests whether the target is the PS5 platform.
bool isPS5() const {
return getArch() == Triple::x86_64 &&
getVendor() == Triple::SCEI &&
getOS() == Triple::PS5;
return getArch() == Triple::x86_64 && getVendor() == Triple::SCEI &&
getOS() == Triple::PS5;
}
/// Tests whether the target is the PS4 or PS5 platform.
@ -900,13 +847,9 @@ public:
bool isOSLiteOS() const { return getOS() == Triple::LiteOS; }
/// Tests whether the target is DXIL.
bool isDXIL() const {
return getArch() == Triple::dxil;
}
bool isDXIL() const { return getArch() == Triple::dxil; }
bool isShaderModelOS() const {
return getOS() == Triple::ShaderModel;
}
bool isShaderModelOS() const { return getOS() == Triple::ShaderModel; }
bool isVulkanOS() const { return getOS() == Triple::Vulkan; }
@ -941,9 +884,7 @@ public:
bool isSPIROrSPIRV() const { return isSPIR() || isSPIRV(); }
/// Tests whether the target is SPIR-V Logical
bool isSPIRVLogical() const {
return getArch() == Triple::spirv;
}
bool isSPIRVLogical() const { return getArch() == Triple::spirv; }
/// Tests whether the target is NVPTX (32- or 64-bit).
bool isNVPTX() const {
@ -1091,9 +1032,7 @@ public:
}
/// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
bool isMIPS() const {
return isMIPS32() || isMIPS64();
}
bool isMIPS() const { return isMIPS32() || isMIPS64(); }
/// Tests whether the target is PowerPC (32- or 64-bit LE or BE).
bool isPPC() const {
@ -1153,9 +1092,7 @@ public:
bool isSPARC() const { return isSPARC32() || isSPARC64(); }
/// Tests whether the target is SystemZ.
bool isSystemZ() const {
return getArch() == Triple::systemz;
}
bool isSystemZ() const { return getArch() == Triple::systemz; }
/// Tests whether the target is x86 (32- or 64-bit).
bool isX86() const {
@ -1169,9 +1106,7 @@ public:
bool isX86_64() const { return getArch() == Triple::x86_64; }
/// Tests whether the target is VE
bool isVE() const {
return getArch() == Triple::ve;
}
bool isVE() const { return getArch() == Triple::ve; }
/// Tests whether the target is wasm (32- and 64-bit).
bool isWasm() const {
@ -1179,9 +1114,7 @@ public:
}
// Tests whether the target is CSKY
bool isCSKY() const {
return getArch() == Triple::csky;
}
bool isCSKY() const { return getArch() == Triple::csky; }
/// Tests whether the target is the Apple "arm64e" AArch64 subarch.
bool isArm64e() const {
@ -1225,8 +1158,7 @@ public:
EnvironmentType Env = getEnvironment();
return Env == llvm::Triple::GNUEABIHF ||
Env == llvm::Triple::GNUEABIHFT64 ||
Env == llvm::Triple::MuslEABIHF ||
Env == llvm::Triple::EABIHF;
Env == llvm::Triple::MuslEABIHF || Env == llvm::Triple::EABIHF;
}
/// Tests whether the target supports comdat
@ -1413,7 +1345,6 @@ public:
LLVM_ABI std::string computeDataLayout(StringRef ABIName = "") const;
};
} // End llvm namespace
} // namespace llvm
#endif

View File

@ -0,0 +1,16 @@
add_llvm_component_library(LLVMStakrAsmParser
StakrAsmParser.cpp
StakrAsmTypeCheck.cpp
LINK_COMPONENTS
CodeGenTypes
MC
MCParser
Support
TargetParser
StakrDesc
StakrInfo
ADD_TO_COMPONENT
Stakr
)

View File

@ -0,0 +1,48 @@
add_llvm_component_group(Stakr)
set(LLVM_TARGET_DEFINITIONS Stakr.td)
tablegen(LLVM StakrGenSubtargetInfo.td -gen-subtarget)
tablegen(LLVM StakrGenRegisterInfo.inc -gen-register-info)
tablegen(LLVM StakrGenInstrInfo.inc -gen-instr-info)
tablegen(LLVM StakrGenAsmWriter.inc -gen-asm-writer)
tablegen(LLVM StakrGenAsmMatcher.inc -gen-asm-matcher)
tablegen(LLVM StakrGenAsmEmitter.inc -gen-emitter)
tablegen(LLVM StakrGenCallingConv.inc -gen-callingconv)
tablegen(LLVM StakrGenDAGISel.inc -gen-dag-isel)
add_public_tablegen_target(StakrCommonTableGen)
add_llvm_target(StakrCodeGen
StakrAsmPrinter.cpp
StakrFrameLowering.cpp
StakrInstrInfo.cpp
StakrISelDAGToDAG.cpp
StakrISelLowering.cpp
StakrMachineFunctionInfo.cpp
StakrRegisterInfo.cpp
StakrSubtarget.cpp
StakrTargetMachine.cpp
StakrTargetObjectFile.cpp
LINK_COMPONENTS
Analysis
AsmPrinter
BinaryFormat
CodeGen
CodeGenTypes
Core
MC
SelectionDAG
Support
Target
TargetParser
TransformUtils
ADD_TO_COMPONENT
Stakr
)
add_subdirectory(AsmParser)
add_subdirectory(MCTargetDesc)
add_subdirectory(TargetInfo)

View File

@ -0,0 +1,20 @@
add_llvm_component_library(LLVMStakrDesc
StakrAsmBackend.cpp
StakrInstPrinter.cpp
StakrMCAsmInfo.cpp
StakrMCCodeEmitter.cpp
StakrMCTargetDesc.cpp
StakrMCTypeUtilities.cpp
StakrTargetStreamer.cpp
StakrELFObjectWriter.cpp
LINK_COMPONENTS
CodeGenTypes
MC
Support
TargetParser
StakrInfo
ADD_TO_COMPONENT
Stakr
)

View File

@ -0,0 +1,23 @@
include "llvm/Target/Target.td"
include "StakrRegisterInfo.td"
include "StakrInstrInfo.td"
def StakrInstrInfo : InstrInfo;
def StakrAsmParser : AsmParser {
let ShouldEmitMatchRegisterName = 0;
}
def StakrAsmWriter : AsmWriter {
string AsmWriterClassName = "InstPrinter";
int PassSubtarget = 0;
int Variant = 0;
bit isMCAsmWriter = 1;
}
def Stakr : Target {
let InstructionSet = StakrInstrInfo;
let AssemblyParsers = [StakrAsmParser];
let AssemblyWriters = [StakrAsmWriter];
}

View File

@ -0,0 +1,40 @@
class StakrInst<bits<2> opwidth, bits<5> inst, string asmstr, bit stack>
: StackRel, RegisterRel, Instruction {
bits<8> Inst;
bit StackBased = stack;
string BaseName = NAME;
let Namespace = "Stakr";
let Pattern = [];
let AsmString = asmstr;
bit IsCanonical = 0;
let Inst{7} = 0;
let Inst{6-5} = opwidth;
let Inst{4-0} = inst;
}
class NI<dag oops, dag iops, list<dag> pattern, bit stack,
string asmstr = "", bits<2> opwidth, bits<5> inst>
: StakrInst<opwidth, inst, asmstr, stack> {
dag OutOperandList = oops;
dag InOperandList = iops;
let Pattern = pattern;
}
multiclass WNI<dag oops, dag iops, list<dag> pattern, bit stack,
string asmstr = "", bits<5> inst> {
def "8": NI<oops, iops, pattern, stack, asmstr, 0b00, inst>;
def "16": NI<oops, iops, pattern, stack, asmstr, 0b01, inst>;
def "32": NI<oops, iops, pattern, stack, asmstr, 0b10, inst>;
def "64": NI<oops, iops, pattern, stack, asmstr, 0b11, inst>;
}
multiclass I<dag oops_r, dag iops_r, dag oops_s, dag iops_s,
list<dag> pattern_r, string asmstr_r = "", string asmstr_s = "",
bits<5> inst = -1> {
let isCodeGenOnly = 1 in
defm "": WNI<oops_r, iops_r, pattern_r, false, asmstr_r, inst>;
let BaseName = NAME in
defm _S : WNI<oops_s, iops_s, [], true, asmstr_s, inst>;
}

View File

View File

@ -0,0 +1,31 @@
def SDT_StakrCallSeqStart : SDCallSeqStart<[SDTCisVT<0, iPTR>,
SDTCisVT<1, iPTR>]>;
def SDT_StakrCallSeqEnd :
SDCallSeqEnd<[SDTCisVT<0, iPTR>, SDTCisVT<1, iPTR>]>;
class StackRel;
def getStackOpcode : InstrMapping {
let FilterClass = "StackRel";
let RowFields = ["BaseName"];
let ColFields = ["StackBased"];
let KeyCol = ["0"];
let ValueCols = [["1"]];
}
class RegisterRel;
def getRegisterOpcode : InstrMapping {
let FilterClass = "RegisterRel";
let RowFields = ["BaseName"];
let ColFields = ["StackBased"];
let KeyCol = ["1"];
let ValueCols = [["0"]];
}
include "StakrInstrFormats.td"
let isMoveImm = 1, isAsCheapAsAMove = 1, isReMaterializable = 1 in {
defm CONST : I<(outs I32:$res), (ins i32imm:$imm),
(outs), (ins i32imm:$imm),
[(set I32:$res, imm:$imm)],
"const\t$res, $imm", "const\t$imm", 0b00000>;
}

View File

@ -0,0 +1,17 @@
class StakrReg<string n> : Register<n> {
let Namespace = "Stakr";
}
class StakrRegClass<list<ValueType> regTypes, int alignment, dag regList>
: RegisterClass<"Stakr", regTypes, alignment, regList>;
def FP : StakrReg<"%FP">;
def SP : StakrReg<"%SP">;
def I32_0 : StakrReg<"%i32.0">;
def VALUE_STACK : StakrReg<"STACK">;
def I32 : StakrRegClass<[i32], 32, (add FP, SP, I32_0)>;
defm "": RemapAllTargetPseudoPointerOperands<I32>;

View File

View File

@ -0,0 +1,14 @@
include_directories(${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/..)
add_llvm_component_library(LLVMStakrInfo
StakrTargetInfo.cpp
LINK_COMPONENTS
MC
Support
ADD_TO_COMPONENT
Stakr
)
add_dependencies(LLVMStakrInfo StakrCommonTableGen)

File diff suppressed because it is too large Load Diff