mirror of
https://github.com/RPCSX/llvm.git
synced 2025-03-02 09:58:06 +00:00
Odd additional stub framework for the ARM MC ELF emission.
llc now recognizes the "intent" to support MC/obj emission for ARM, but given that they are all stubs, it asserts on --filetype=obj --march=arm Patch by Jason Kim. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114856 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b814110612
commit
fd9493d74e
65
lib/Target/ARM/ARMELFWriterInfo.cpp
Normal file
65
lib/Target/ARM/ARMELFWriterInfo.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
//===-- ARMELFWriterInfo.cpp - ELF Writer Info for the ARM backend --------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file implements ELF writer information for the ARM backend.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "ARMELFWriterInfo.h"
|
||||||
|
#include "ARMRelocations.h"
|
||||||
|
#include "llvm/Function.h"
|
||||||
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
#include "llvm/Target/TargetData.h"
|
||||||
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// Implementation of the ARMELFWriterInfo class
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
ARMELFWriterInfo::ARMELFWriterInfo(TargetMachine &TM)
|
||||||
|
: TargetELFWriterInfo(TM) {
|
||||||
|
// silently OK construction
|
||||||
|
}
|
||||||
|
|
||||||
|
ARMELFWriterInfo::~ARMELFWriterInfo() {}
|
||||||
|
|
||||||
|
unsigned ARMELFWriterInfo::getRelocationType(unsigned MachineRelTy) const {
|
||||||
|
assert(0 && "ARMELFWriterInfo::getRelocationType() not implemented");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long int ARMELFWriterInfo::getDefaultAddendForRelTy(unsigned RelTy,
|
||||||
|
long int Modifier) const {
|
||||||
|
assert(0 && "ARMELFWriterInfo::getDefaultAddendForRelTy() not implemented");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned ARMELFWriterInfo::getRelocationTySize(unsigned RelTy) const {
|
||||||
|
assert(0 && "ARMELFWriterInfo::getRelocationTySize() not implemented");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ARMELFWriterInfo::isPCRelativeRel(unsigned RelTy) const {
|
||||||
|
assert(0 && "ARMELFWriterInfo::isPCRelativeRel() not implemented");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned ARMELFWriterInfo::getAbsoluteLabelMachineRelTy() const {
|
||||||
|
assert(0 && "ARMELFWriterInfo::getAbsoluteLabelMachineRelTy() not implemented");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long int ARMELFWriterInfo::computeRelocation(unsigned SymOffset,
|
||||||
|
unsigned RelOffset,
|
||||||
|
unsigned RelTy) const {
|
||||||
|
assert(0 && "ARMELFWriterInfo::getAbsoluteLabelMachineRelTy() not implemented");
|
||||||
|
return 0;
|
||||||
|
}
|
66
lib/Target/ARM/ARMELFWriterInfo.h
Normal file
66
lib/Target/ARM/ARMELFWriterInfo.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
//===-- ARMELFWriterInfo.h - ELF Writer Info for ARM ------------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file implements ELF writer information for the ARM backend.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef ARM_ELF_WRITER_INFO_H
|
||||||
|
#define ARM_ELF_WRITER_INFO_H
|
||||||
|
|
||||||
|
#include "llvm/Target/TargetELFWriterInfo.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
|
||||||
|
class ARMELFWriterInfo : public TargetELFWriterInfo {
|
||||||
|
|
||||||
|
// ELF Relocation types for ARM
|
||||||
|
// FIXME: TODO(jasonwkim): [2010/09/17 14:52:25 PDT (Friday)]
|
||||||
|
// Come up with a better way to orgnize the 100+ ARM reloc types.
|
||||||
|
|
||||||
|
enum ARMRelocationType {
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
ARMELFWriterInfo(TargetMachine &TM);
|
||||||
|
virtual ~ARMELFWriterInfo();
|
||||||
|
|
||||||
|
/// getRelocationType - Returns the target specific ELF Relocation type.
|
||||||
|
/// 'MachineRelTy' contains the object code independent relocation type
|
||||||
|
virtual unsigned getRelocationType(unsigned MachineRelTy) const;
|
||||||
|
|
||||||
|
/// hasRelocationAddend - True if the target uses an addend in the
|
||||||
|
/// ELF relocation entry.
|
||||||
|
virtual bool hasRelocationAddend() const { return false; }
|
||||||
|
|
||||||
|
/// getDefaultAddendForRelTy - Gets the default addend value for a
|
||||||
|
/// relocation entry based on the target ELF relocation type.
|
||||||
|
virtual long int getDefaultAddendForRelTy(unsigned RelTy,
|
||||||
|
long int Modifier = 0) const;
|
||||||
|
|
||||||
|
/// getRelTySize - Returns the size of relocatable field in bits
|
||||||
|
virtual unsigned getRelocationTySize(unsigned RelTy) const;
|
||||||
|
|
||||||
|
/// isPCRelativeRel - True if the relocation type is pc relative
|
||||||
|
virtual bool isPCRelativeRel(unsigned RelTy) const;
|
||||||
|
|
||||||
|
/// getJumpTableRelocationTy - Returns the machine relocation type used
|
||||||
|
/// to reference a jumptable.
|
||||||
|
virtual unsigned getAbsoluteLabelMachineRelTy() const;
|
||||||
|
|
||||||
|
/// computeRelocation - Some relocatable fields could be relocated
|
||||||
|
/// directly, avoiding the relocation symbol emission, compute the
|
||||||
|
/// final relocation value for this symbol.
|
||||||
|
virtual long int computeRelocation(unsigned SymOffset, unsigned RelOffset,
|
||||||
|
unsigned RelTy) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end llvm namespace
|
||||||
|
|
||||||
|
#endif // ARM_ELF_WRITER_INFO_H
|
@ -204,6 +204,29 @@ protected:
|
|||||||
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
|
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
|
||||||
/// symbol.
|
/// symbol.
|
||||||
bool GVIsIndirectSymbol(const GlobalValue *GV, Reloc::Model RelocM) const;
|
bool GVIsIndirectSymbol(const GlobalValue *GV, Reloc::Model RelocM) const;
|
||||||
|
|
||||||
|
/// getDataLayout() - returns the ARM/Thumb specific TargetLayout string
|
||||||
|
std::string getDataLayout() const {
|
||||||
|
if (isThumb()) {
|
||||||
|
if (isAPCS_ABI()) {
|
||||||
|
return std::string("e-p:32:32-f64:32:32-i64:32:32-"
|
||||||
|
"i16:16:32-i8:8:32-i1:8:32-"
|
||||||
|
"v128:32:128-v64:32:64-a:0:32-n32");
|
||||||
|
} else {
|
||||||
|
return std::string("e-p:32:32-f64:64:64-i64:64:64-"
|
||||||
|
"i16:16:32-i8:8:32-i1:8:32-"
|
||||||
|
"v128:64:128-v64:64:64-a:0:32-n32");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isAPCS_ABI()) {
|
||||||
|
return std::string("e-p:32:32-f64:32:32-i64:32:32-"
|
||||||
|
"v128:32:128-v64:32:64-n32");
|
||||||
|
} else {
|
||||||
|
return std::string("e-p:32:32-f64:64:64-i64:64:64-"
|
||||||
|
"v128:64:128-v64:64:64-n32");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
|
@ -31,6 +31,26 @@ static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is duplicated code. Refactor this.
|
||||||
|
static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
|
||||||
|
MCContext &Ctx, TargetAsmBackend &TAB,
|
||||||
|
raw_ostream &_OS,
|
||||||
|
MCCodeEmitter *_Emitter,
|
||||||
|
bool RelaxAll) {
|
||||||
|
Triple TheTriple(TT);
|
||||||
|
switch (TheTriple.getOS()) {
|
||||||
|
case Triple::Darwin:
|
||||||
|
return createMachOStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll);
|
||||||
|
case Triple::MinGW32:
|
||||||
|
case Triple::MinGW64:
|
||||||
|
case Triple::Cygwin:
|
||||||
|
case Triple::Win32:
|
||||||
|
assert(0 && "ARM does not support Windows COFF format"); break;
|
||||||
|
default:
|
||||||
|
return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void LLVMInitializeARMTarget() {
|
extern "C" void LLVMInitializeARMTarget() {
|
||||||
// Register the target.
|
// Register the target.
|
||||||
RegisterTargetMachine<ARMTargetMachine> X(TheARMTarget);
|
RegisterTargetMachine<ARMTargetMachine> X(TheARMTarget);
|
||||||
@ -39,6 +59,19 @@ extern "C" void LLVMInitializeARMTarget() {
|
|||||||
// Register the target asm info.
|
// Register the target asm info.
|
||||||
RegisterAsmInfoFn A(TheARMTarget, createMCAsmInfo);
|
RegisterAsmInfoFn A(TheARMTarget, createMCAsmInfo);
|
||||||
RegisterAsmInfoFn B(TheThumbTarget, createMCAsmInfo);
|
RegisterAsmInfoFn B(TheThumbTarget, createMCAsmInfo);
|
||||||
|
|
||||||
|
// Register the MC Code Emitter
|
||||||
|
TargetRegistry::RegisterCodeEmitter(TheARMTarget,
|
||||||
|
createARMMCCodeEmitter);
|
||||||
|
TargetRegistry::RegisterCodeEmitter(TheThumbTarget,
|
||||||
|
createARMMCCodeEmitter);
|
||||||
|
|
||||||
|
// Register the object streamer.
|
||||||
|
TargetRegistry::RegisterObjectStreamer(TheARMTarget,
|
||||||
|
createMCStreamer);
|
||||||
|
TargetRegistry::RegisterObjectStreamer(TheThumbTarget,
|
||||||
|
createMCStreamer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TargetMachine ctor - Create an ARM architecture model.
|
/// TargetMachine ctor - Create an ARM architecture model.
|
||||||
@ -51,18 +84,17 @@ ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T,
|
|||||||
Subtarget(TT, FS, isThumb),
|
Subtarget(TT, FS, isThumb),
|
||||||
FrameInfo(Subtarget),
|
FrameInfo(Subtarget),
|
||||||
JITInfo(),
|
JITInfo(),
|
||||||
InstrItins(Subtarget.getInstrItineraryData()) {
|
InstrItins(Subtarget.getInstrItineraryData()),
|
||||||
|
DataLayout(Subtarget.getDataLayout()),
|
||||||
|
ELFWriterInfo(*this)
|
||||||
|
{
|
||||||
DefRelocModel = getRelocationModel();
|
DefRelocModel = getRelocationModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
ARMTargetMachine::ARMTargetMachine(const Target &T, const std::string &TT,
|
ARMTargetMachine::ARMTargetMachine(const Target &T, const std::string &TT,
|
||||||
const std::string &FS)
|
const std::string &FS)
|
||||||
: ARMBaseTargetMachine(T, TT, FS, false), InstrInfo(Subtarget),
|
: ARMBaseTargetMachine(T, TT, FS, false),
|
||||||
DataLayout(Subtarget.isAPCS_ABI() ?
|
InstrInfo(Subtarget),
|
||||||
std::string("e-p:32:32-f64:32:32-i64:32:32-"
|
|
||||||
"v128:32:128-v64:32:64-n32") :
|
|
||||||
std::string("e-p:32:32-f64:64:64-i64:64:64-"
|
|
||||||
"v128:64:128-v64:64:64-n32")),
|
|
||||||
TLInfo(*this),
|
TLInfo(*this),
|
||||||
TSInfo(*this) {
|
TSInfo(*this) {
|
||||||
if (!Subtarget.hasARMOps())
|
if (!Subtarget.hasARMOps())
|
||||||
@ -76,13 +108,6 @@ ThumbTargetMachine::ThumbTargetMachine(const Target &T, const std::string &TT,
|
|||||||
InstrInfo(Subtarget.hasThumb2()
|
InstrInfo(Subtarget.hasThumb2()
|
||||||
? ((ARMBaseInstrInfo*)new Thumb2InstrInfo(Subtarget))
|
? ((ARMBaseInstrInfo*)new Thumb2InstrInfo(Subtarget))
|
||||||
: ((ARMBaseInstrInfo*)new Thumb1InstrInfo(Subtarget))),
|
: ((ARMBaseInstrInfo*)new Thumb1InstrInfo(Subtarget))),
|
||||||
DataLayout(Subtarget.isAPCS_ABI() ?
|
|
||||||
std::string("e-p:32:32-f64:32:32-i64:32:32-"
|
|
||||||
"i16:16:32-i8:8:32-i1:8:32-"
|
|
||||||
"v128:32:128-v64:32:64-a:0:32-n32") :
|
|
||||||
std::string("e-p:32:32-f64:64:64-i64:64:64-"
|
|
||||||
"i16:16:32-i8:8:32-i1:8:32-"
|
|
||||||
"v128:64:128-v64:64:64-a:0:32-n32")),
|
|
||||||
TLInfo(*this),
|
TLInfo(*this),
|
||||||
TSInfo(*this) {
|
TSInfo(*this) {
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "ARMInstrInfo.h"
|
#include "ARMInstrInfo.h"
|
||||||
|
#include "ARMELFWriterInfo.h"
|
||||||
#include "ARMFrameInfo.h"
|
#include "ARMFrameInfo.h"
|
||||||
#include "ARMJITInfo.h"
|
#include "ARMJITInfo.h"
|
||||||
#include "ARMSubtarget.h"
|
#include "ARMSubtarget.h"
|
||||||
@ -38,10 +40,19 @@ private:
|
|||||||
InstrItineraryData InstrItins;
|
InstrItineraryData InstrItins;
|
||||||
Reloc::Model DefRelocModel; // Reloc model before it's overridden.
|
Reloc::Model DefRelocModel; // Reloc model before it's overridden.
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const TargetData DataLayout; // Calculates type size & alignment
|
||||||
|
ARMELFWriterInfo ELFWriterInfo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ARMBaseTargetMachine(const Target &T, const std::string &TT,
|
ARMBaseTargetMachine(const Target &T, const std::string &TT,
|
||||||
const std::string &FS, bool isThumb);
|
const std::string &FS, bool isThumb);
|
||||||
|
|
||||||
|
virtual const TargetData *getTargetData() const { return &DataLayout; }
|
||||||
|
virtual const ARMELFWriterInfo *getELFWriterInfo() const {
|
||||||
|
return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
|
||||||
|
};
|
||||||
|
|
||||||
virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; }
|
virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; }
|
||||||
virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
|
virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
|
||||||
virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
|
virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
|
||||||
@ -63,7 +74,6 @@ public:
|
|||||||
///
|
///
|
||||||
class ARMTargetMachine : public ARMBaseTargetMachine {
|
class ARMTargetMachine : public ARMBaseTargetMachine {
|
||||||
ARMInstrInfo InstrInfo;
|
ARMInstrInfo InstrInfo;
|
||||||
const TargetData DataLayout; // Calculates type size & alignment
|
|
||||||
ARMTargetLowering TLInfo;
|
ARMTargetLowering TLInfo;
|
||||||
ARMSelectionDAGInfo TSInfo;
|
ARMSelectionDAGInfo TSInfo;
|
||||||
public:
|
public:
|
||||||
@ -93,7 +103,6 @@ public:
|
|||||||
class ThumbTargetMachine : public ARMBaseTargetMachine {
|
class ThumbTargetMachine : public ARMBaseTargetMachine {
|
||||||
// Either Thumb1InstrInfo or Thumb2InstrInfo.
|
// Either Thumb1InstrInfo or Thumb2InstrInfo.
|
||||||
OwningPtr<ARMBaseInstrInfo> InstrInfo;
|
OwningPtr<ARMBaseInstrInfo> InstrInfo;
|
||||||
const TargetData DataLayout; // Calculates type size & alignment
|
|
||||||
ARMTargetLowering TLInfo;
|
ARMTargetLowering TLInfo;
|
||||||
ARMSelectionDAGInfo TSInfo;
|
ARMSelectionDAGInfo TSInfo;
|
||||||
public:
|
public:
|
||||||
|
@ -21,6 +21,7 @@ add_llvm_target(ARMCodeGen
|
|||||||
ARMCodeEmitter.cpp
|
ARMCodeEmitter.cpp
|
||||||
ARMConstantIslandPass.cpp
|
ARMConstantIslandPass.cpp
|
||||||
ARMConstantPoolValue.cpp
|
ARMConstantPoolValue.cpp
|
||||||
|
ARMELFWriterInfo.cpp
|
||||||
ARMExpandPseudoInsts.cpp
|
ARMExpandPseudoInsts.cpp
|
||||||
ARMFastISel.cpp
|
ARMFastISel.cpp
|
||||||
ARMGlobalMerge.cpp
|
ARMGlobalMerge.cpp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user