Showing with 8,868 additions and 4 deletions.
  1. +1 −1 bindings/python/llvm/disassembler.py
  2. +2 −0 cmake/config-ix.cmake
  3. +2 −1 include/llvm/ADT/Triple.h
  4. +1 −1 include/llvm/CodeGen/AsmPrinter.h
  5. +18 −0 include/llvm/CodeGen/MachineRegisterInfo.h
  6. +2 −0 include/llvm/Object/ELFObjectFile.h
  7. +7 −0 include/llvm/Support/ELF.h
  8. +23 −0 include/llvm/Support/ELFRelocs/AAP.def
  9. +1 −0 include/llvm/module.modulemap
  10. +6 −1 lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  11. +7 −0 lib/CodeGen/MachineRegisterInfo.cpp
  12. +8 −0 lib/CodeGen/TargetFrameLoweringImpl.cpp
  13. +7 −0 lib/Object/ELF.cpp
  14. +3 −0 lib/ObjectYAML/ELFYAML.cpp
  15. +10 −0 lib/Support/Triple.cpp
  16. +67 −0 lib/Target/AAP/AAP.h
  17. +47 −0 lib/Target/AAP/AAP.td
  18. +98 −0 lib/Target/AAP/AAPAsmPrinter.cpp
  19. +45 −0 lib/Target/AAP/AAPCallingConv.td
  20. +131 −0 lib/Target/AAP/AAPFrameLowering.cpp
  21. +43 −0 lib/Target/AAP/AAPFrameLowering.h
  22. +205 −0 lib/Target/AAP/AAPISelDAGToDAG.cpp
  23. +830 −0 lib/Target/AAP/AAPISelLowering.cpp
  24. +148 −0 lib/Target/AAP/AAPISelLowering.h
  25. +282 −0 lib/Target/AAP/AAPInstrFormats.td
  26. +131 −0 lib/Target/AAP/AAPInstrInfo.cpp
  27. +67 −0 lib/Target/AAP/AAPInstrInfo.h
  28. +636 −0 lib/Target/AAP/AAPInstrInfo.td
  29. +168 −0 lib/Target/AAP/AAPMCInstLower.cpp
  30. +47 −0 lib/Target/AAP/AAPMCInstLower.h
  31. +23 −0 lib/Target/AAP/AAPMachineFunctionInfo.cpp
  32. +65 −0 lib/Target/AAP/AAPMachineFunctionInfo.h
  33. +119 −0 lib/Target/AAP/AAPRegisterInfo.cpp
  34. +54 −0 lib/Target/AAP/AAPRegisterInfo.h
  35. +35 −0 lib/Target/AAP/AAPRegisterInfo.td
  36. +20 −0 lib/Target/AAP/AAPSelectionDAGInfo.cpp
  37. +30 −0 lib/Target/AAP/AAPSelectionDAGInfo.h
  38. +366 −0 lib/Target/AAP/AAPShortInstrPeephole.cpp
  39. +32 −0 lib/Target/AAP/AAPSubtarget.cpp
  40. +67 −0 lib/Target/AAP/AAPSubtarget.h
  41. +68 −0 lib/Target/AAP/AAPTargetMachine.cpp
  42. +47 −0 lib/Target/AAP/AAPTargetMachine.h
  43. +677 −0 lib/Target/AAP/AsmParser/AAPAsmParser.cpp
  44. +5 −0 lib/Target/AAP/AsmParser/CMakeLists.txt
  45. +23 −0 lib/Target/AAP/AsmParser/LLVMBuild.txt
  46. +33 −0 lib/Target/AAP/CMakeLists.txt
  47. +144 −0 lib/Target/AAP/Disassembler/AAPDisassembler.cpp
  48. +36 −0 lib/Target/AAP/Disassembler/AAPDisassembler.h
  49. +7 −0 lib/Target/AAP/Disassembler/CMakeLists.txt
  50. +23 −0 lib/Target/AAP/Disassembler/LLVMBuild.txt
  51. +103 −0 lib/Target/AAP/InstPrinter/AAPInstPrinter.cpp
  52. +57 −0 lib/Target/AAP/InstPrinter/AAPInstPrinter.h
  53. +3 −0 lib/Target/AAP/InstPrinter/CMakeLists.txt
  54. +23 −0 lib/Target/AAP/InstPrinter/LLVMBuild.txt
  55. +34 −0 lib/Target/AAP/LLVMBuild.txt
  56. +178 −0 lib/Target/AAP/MCTargetDesc/AAPAsmBackend.cpp
  57. +82 −0 lib/Target/AAP/MCTargetDesc/AAPELFObjectWriter.cpp
  58. +58 −0 lib/Target/AAP/MCTargetDesc/AAPFixupKinds.h
  59. +27 −0 lib/Target/AAP/MCTargetDesc/AAPMCAsmInfo.cpp
  60. +32 −0 lib/Target/AAP/MCTargetDesc/AAPMCAsmInfo.h
  61. +283 −0 lib/Target/AAP/MCTargetDesc/AAPMCCodeEmitter.cpp
  62. +97 −0 lib/Target/AAP/MCTargetDesc/AAPMCCodeEmitter.h
  63. +95 −0 lib/Target/AAP/MCTargetDesc/AAPMCTargetDesc.cpp
  64. +57 −0 lib/Target/AAP/MCTargetDesc/AAPMCTargetDesc.h
  65. +7 −0 lib/Target/AAP/MCTargetDesc/CMakeLists.txt
  66. +23 −0 lib/Target/AAP/MCTargetDesc/LLVMBuild.txt
  67. +19 −0 lib/Target/AAP/TargetInfo/AAPTargetInfo.cpp
  68. +3 −0 lib/Target/AAP/TargetInfo/CMakeLists.txt
  69. +23 −0 lib/Target/AAP/TargetInfo/LLVMBuild.txt
  70. +128 −0 lib/Target/AAPSimulator/AAPSimState.cpp
  71. +92 −0 lib/Target/AAPSimulator/AAPSimState.h
  72. +693 −0 lib/Target/AAPSimulator/AAPSimulator.cpp
  73. +65 −0 lib/Target/AAPSimulator/AAPSimulator.h
  74. +10 −0 lib/Target/AAPSimulator/CMakeLists.txt
  75. +23 −0 lib/Target/AAPSimulator/LLVMBuild.txt
  76. +14 −0 lib/Target/AAPSimulator/README.txt
  77. +3 −0 lib/Target/CMakeLists.txt
  78. +2 −0 lib/Target/LLVMBuild.txt
  79. +100 −0 test/CodeGen/AAP/add-sub.ll
  80. +406 −0 test/CodeGen/AAP/load-offset.ll
  81. +69 −0 test/CodeGen/AAP/load.ll
  82. +64 −0 test/CodeGen/AAP/logical.ll
  83. +85 −0 test/CodeGen/AAP/shift.ll
  84. +105 −0 test/CodeGen/AAP/store-offset.ll
  85. +195 −0 test/CodeGen/AAP/store.ll
  86. +108 −0 test/CodeGen/AAP/truncstore.ll
  87. +90 −0 test/MC/AAP/alu.s
  88. +22 −0 test/MC/AAP/branch.s
  89. +102 −0 test/MC/AAP/load.s
  90. +38 −0 test/MC/AAP/move.s
  91. +10 −0 test/MC/AAP/noop.s
  92. +98 −0 test/MC/AAP/store.s
  93. +1 −0 tools/LLVMBuild.txt
  94. +164 −0 tools/aap-run/AAPSimTest.cpp
  95. +21 −0 tools/aap-run/CMakeLists.txt
  96. +22 −0 tools/aap-run/LLVMBuild.txt
  97. +17 −0 tools/aap-run/Makefile
2 changes: 1 addition & 1 deletion bindings/python/llvm/disassembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@


_initialized = False
_targets = ['AArch64', 'ARM', 'Hexagon', 'MSP430', 'Mips', 'NVPTX', 'PowerPC', 'R600', 'Sparc', 'SystemZ', 'X86', 'XCore']
_targets = ['AArch64', 'ARM', 'Hexagon', 'MSP430', 'Mips', 'NVPTX', 'PowerPC', 'R600', 'Sparc', 'SystemZ', 'AAP', 'X86', 'XCore']
def _ensure_initialized():
global _initialized
if not _initialized:
Expand Down
2 changes: 2 additions & 0 deletions cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ elseif (LLVM_NATIVE_ARCH MATCHES "wasm32")
set(LLVM_NATIVE_ARCH WebAssembly)
elseif (LLVM_NATIVE_ARCH MATCHES "wasm64")
set(LLVM_NATIVE_ARCH WebAssembly)
elseif (LLVM_NATIVE_ARCH MATCHES "aap")
set(LLVM_NATIVE_ARCH AAP)
else ()
message(FATAL_ERROR "Unknown architecture ${LLVM_NATIVE_ARCH}")
endif ()
Expand Down
3 changes: 2 additions & 1 deletion include/llvm/ADT/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class Triple {
wasm64, // WebAssembly with 64-bit pointers
renderscript32, // 32-bit RenderScript
renderscript64, // 64-bit RenderScript
LastArchType = renderscript64
aap, // AAP architecture
LastArchType = aap
};
enum SubArchType {
NoSubArch,
Expand Down
2 changes: 1 addition & 1 deletion include/llvm/CodeGen/AsmPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class AsmPrinter : public MachineFunctionPass {
const DataLayout &getDataLayout() const;

/// Return the pointer size from the TargetMachine
unsigned getPointerSize() const;
virtual unsigned getPointerSize() const;

/// Return information about subtarget.
const MCSubtargetInfo &getSubtargetInfo() const;
Expand Down
18 changes: 18 additions & 0 deletions include/llvm/CodeGen/MachineRegisterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ class MachineRegisterInfo {
/// second element.
std::vector<std::pair<unsigned, unsigned> > LiveIns;

/// Keep track of the physical registers that are live out of the function.
/// Live out values are return values in registers.
std::vector<unsigned> LiveOuts;

MachineRegisterInfo(const MachineRegisterInfo&) = delete;
void operator=(const MachineRegisterInfo&) = delete;
public:
Expand Down Expand Up @@ -797,6 +801,12 @@ class MachineRegisterInfo {
LiveIns.push_back(std::make_pair(Reg, vreg));
}

/// addLiveOut - Add the specified register as a live-out. Note that it
/// is an error to add the same register to the same set more than once.
void addLiveOut(unsigned Reg) {
LiveOuts.push_back(Reg);
}

// Iteration support for the live-ins set. It's kept in sorted order
// by register number.
typedef std::vector<std::pair<unsigned,unsigned> >::const_iterator
Expand All @@ -807,6 +817,14 @@ class MachineRegisterInfo {

bool isLiveIn(unsigned Reg) const;

// Iteration support for the live-outs set. Not necessarily in sorted order.
typedef std::vector<unsigned>::const_iterator liveout_iterator;
liveout_iterator liveout_begin() const { return LiveOuts.begin(); }
liveout_iterator liveout_end() const { return LiveOuts.end(); }
bool liveout_empty() const { return LiveOuts.empty(); }

bool isLiveOut(unsigned Reg) const;

/// getLiveInPhysReg - If VReg is a live-in virtual register, return the
/// corresponding live-in physical register.
unsigned getLiveInPhysReg(unsigned VReg) const;
Expand Down
2 changes: 2 additions & 0 deletions include/llvm/Object/ELFObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,8 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
return "ELF32-wasm";
case ELF::EM_AMDGPU:
return "ELF32-amdgpu";
case ELF::EM_AAP:
return "ELF32-aap";
default:
return "ELF32-unknown";
}
Expand Down
7 changes: 7 additions & 0 deletions include/llvm/Support/ELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ enum {
// such numbers for an official value for WebAssembly. As soon as one is
// allocated, this enum will be updated to use it.
EM_WEBASSEMBLY = 0x4157, // WebAssembly architecture

EM_AAP = 0x5343 // AAP
};

// Object file classes.
Expand Down Expand Up @@ -622,6 +624,11 @@ enum {
#include "ELFRelocs/BPF.def"
};

// ELF Relocation type for AAP.
enum {
#include "ELFRelocs/AAP.def"
};

#undef ELF_RELOC

// Section header.
Expand Down
23 changes: 23 additions & 0 deletions include/llvm/Support/ELFRelocs/AAP.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

#ifndef ELF_RELOC
#error "ELF_RELOC must be defined"
#endif

ELF_RELOC(R_AAP_NONE, 0x00)
ELF_RELOC(R_AAP_8, 0x01)
ELF_RELOC(R_AAP_16, 0x02)
ELF_RELOC(R_AAP_32, 0x03)
ELF_RELOC(R_AAP_64, 0x04)
ELF_RELOC(R_AAP_BR16, 0x05)
ELF_RELOC(R_AAP_BR32, 0x06)
ELF_RELOC(R_AAP_BRCC16, 0x07)
ELF_RELOC(R_AAP_BRCC32, 0x08)
ELF_RELOC(R_AAP_BAL16, 0x09)
ELF_RELOC(R_AAP_BAL32, 0x0a)
ELF_RELOC(R_AAP_ABS6, 0x0b)
ELF_RELOC(R_AAP_ABS9, 0x0c)
ELF_RELOC(R_AAP_ABS10, 0x0d)
ELF_RELOC(R_AAP_ABS12, 0x0e)
ELF_RELOC(R_AAP_ABS16, 0x0f)
ELF_RELOC(R_AAP_OFF10, 0x10)
ELF_RELOC(R_AAP_SHIFT6, 0x11)
1 change: 1 addition & 0 deletions include/llvm/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ module LLVM_Utils {
textual header "Support/AArch64TargetParser.def"
textual header "Support/Dwarf.def"
textual header "Support/MachO.def"
textual header "Support/ELFRelocs/AAP.def"
textual header "Support/ELFRelocs/AArch64.def"
textual header "Support/ELFRelocs/AMDGPU.def"
textual header "Support/ELFRelocs/ARM.def"
Expand Down
7 changes: 6 additions & 1 deletion lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ const DataLayout &AsmPrinter::getDataLayout() const {

// Do not use the cached DataLayout because some client use it without a Module
// (llmv-dsymutil, llvm-dwarfdump).
unsigned AsmPrinter::getPointerSize() const { return TM.getPointerSize(); }
// By default, use the pointer size defined by the target machine
unsigned AsmPrinter::getPointerSize() const {
if (MAI)
return MAI->getPointerSize();
return TM.getPointerSize();
}

const MCSubtargetInfo &AsmPrinter::getSubtargetInfo() const {
assert(MF && "getSubtargetInfo requires a valid MachineFunction!");
Expand Down
7 changes: 7 additions & 0 deletions lib/CodeGen/MachineRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,13 @@ bool MachineRegisterInfo::isLiveIn(unsigned Reg) const {
return false;
}

bool MachineRegisterInfo::isLiveOut(unsigned Reg) const {
for (liveout_iterator I = liveout_begin(), E = liveout_end(); I != E; ++I)
if (*I == Reg)
return true;
return false;
}

/// getLiveInPhysReg - If VReg is a live-in virtual register, return the
/// corresponding live-in physical register.
unsigned MachineRegisterInfo::getLiveInPhysReg(unsigned VReg) const {
Expand Down
8 changes: 8 additions & 0 deletions lib/CodeGen/TargetFrameLoweringImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ void TargetFrameLowering::determineCalleeSaves(MachineFunction &MF,
if (CallsUnwindInit || MRI.isPhysRegModified(Reg))
SavedRegs.set(Reg);
}

// Don't save any register which is live out of the function
for (unsigned i = 0; CSRegs[i]; ++i) {
unsigned Reg = CSRegs[i];
if (MRI.isLiveOut(Reg)) {
SavedRegs.reset(Reg);
}
}
}

unsigned TargetFrameLowering::getStackAlignmentSkew(
Expand Down
7 changes: 7 additions & 0 deletions lib/Object/ELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type) {
break;
}
break;
case ELF::EM_AAP:
switch (Type) {
#include "llvm/Support/ELFRelocs/AAP.def"
default:
break;
}
break;
case ELF::EM_AARCH64:
switch (Type) {
#include "llvm/Support/ELFRelocs/AArch64.def"
Expand Down
3 changes: 3 additions & 0 deletions lib/ObjectYAML/ELFYAML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ void ScalarEnumerationTraits<ELFYAML::ELF_REL>::enumeration(
break;
case ELF::EM_LANAI:
#include "llvm/Support/ELFRelocs/Lanai.def"
break;
case ELF::EM_AAP:
#include "llvm/Support/ELFRelocs/AAP.def"
break;
case ELF::EM_AMDGPU:
#include "llvm/Support/ELFRelocs/AMDGPU.def"
Expand Down
10 changes: 10 additions & 0 deletions lib/Support/Triple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const char *Triple::getArchTypeName(ArchType Kind) {
case wasm64: return "wasm64";
case renderscript32: return "renderscript32";
case renderscript64: return "renderscript64";
case aap: return "aap";
}

llvm_unreachable("Invalid ArchType!");
Expand Down Expand Up @@ -134,6 +135,7 @@ const char *Triple::getArchTypePrefix(ArchType Kind) {
case shave: return "shave";
case wasm32:
case wasm64: return "wasm";
case aap: return "aap";
}
}

Expand Down Expand Up @@ -286,6 +288,7 @@ Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
.Case("wasm64", wasm64)
.Case("renderscript32", renderscript32)
.Case("renderscript64", renderscript64)
.Case("aap", aap)
.Default(UnknownArch);
}

Expand Down Expand Up @@ -397,6 +400,7 @@ static Triple::ArchType parseArch(StringRef ArchName) {
.Case("wasm64", Triple::wasm64)
.Case("renderscript32", Triple::renderscript32)
.Case("renderscript64", Triple::renderscript64)
.Case("aap", Triple::aap)
.Default(Triple::UnknownArch);

// Some architectures require special parsing logic just to compute the
Expand Down Expand Up @@ -579,6 +583,7 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
return Triple::COFF;
return Triple::ELF;

case Triple::aap:
case Triple::aarch64_be:
case Triple::amdgcn:
case Triple::amdil:
Expand Down Expand Up @@ -1121,6 +1126,7 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {

case llvm::Triple::avr:
case llvm::Triple::msp430:
case llvm::Triple::aap:
return 16;

case llvm::Triple::arm:
Expand Down Expand Up @@ -1196,6 +1202,7 @@ Triple Triple::get32BitArchVariant() const {
case Triple::msp430:
case Triple::systemz:
case Triple::ppc64le:
case Triple::aap:
T.setArch(UnknownArch);
break;

Expand Down Expand Up @@ -1258,6 +1265,7 @@ Triple Triple::get64BitArchVariant() const {
case Triple::xcore:
case Triple::sparcel:
case Triple::shave:
case Triple::aap:
T.setArch(UnknownArch);
break;

Expand Down Expand Up @@ -1334,6 +1342,7 @@ Triple Triple::getBigEndianArchVariant() const {
case Triple::xcore:
case Triple::renderscript32:
case Triple::renderscript64:
case Triple::aap:

// ARM is intentionally unsupported here, changing the architecture would
// drop any arch suffixes.
Expand Down Expand Up @@ -1420,6 +1429,7 @@ bool Triple::isLittleEndian() const {
case Triple::xcore:
case Triple::renderscript32:
case Triple::renderscript64:
case Triple::aap:
return true;
default:
return false;
Expand Down
67 changes: 67 additions & 0 deletions lib/Target/AAP/AAP.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//===-- AAP.h - Top-level interface for AAP representation ------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the entry points for global functions defined in the LLVM
// AAP back-end.
//
//===----------------------------------------------------------------------===//

#ifndef TARGET_AAP_H
#define TARGET_AAP_H

#include "MCTargetDesc/AAPMCTargetDesc.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Target/TargetMachine.h"

namespace AAPCC {
// AAP specific condition codes
enum CondCode {
COND_EQ = 0,
COND_NE = 1,
COND_LTS = 2,
COND_LES = 3,
COND_LTU = 4,
COND_LEU = 5,
COND_INVALID = -1
};
} // end namespace AAP

namespace llvm {
extern Target TheAAPTarget;
class AAPTargetMachine;

FunctionPass *createAAPISelDag(AAPTargetMachine &TM,
CodeGenOpt::Level OptLevel);

FunctionPass *createAAPShortInstrPeepholePass(AAPTargetMachine &TM);

namespace AAP {
// Various helper methods to define operand ranges used throughout the backend
static bool inline isImm3(int64_t I) { return isUInt<3>(I); }
static bool inline isImm6(int64_t I) { return isUInt<6>(I); }
static bool inline isImm9(int64_t I) { return isUInt<9>(I); }
static bool inline isImm10(int64_t I) { return isUInt<10>(I); }
static bool inline isImm12(int64_t I) { return isUInt<12>(I); }

static bool inline isOff3(int64_t I) { return isInt<3>(I); }
static bool inline isOff6(int64_t I) { return isInt<6>(I); }
static bool inline isOff9(int64_t I) { return isInt<9>(I); }
static bool inline isOff10(int64_t I) { return isInt<10>(I); }

static bool inline isField16(int64_t I) {
return isInt<16>(I) || isUInt<16>(I);
}

static bool inline isShiftImm3(int64_t I) { return (I >= 1) && (I <= 8); }
static bool inline isShiftImm6(int64_t I) { return (I >= 1) && (I <= 64); }

} // end of namespace AAP
} // end namespace llvm

#endif
Loading