[llvm] r360722 - [BPF] Create a TargetInfo header. NFC
Richard Trieu via llvm-commits
llvm-commits at lists.llvm.org
Tue May 14 15:54:07 PDT 2019
Author: rtrieu
Date: Tue May 14 15:54:06 2019
New Revision: 360722
URL: http://llvm.org/viewvc/llvm-project?rev=360722&view=rev
Log:
[BPF] Create a TargetInfo header. NFC
Move the declarations of getThe<Name>Target() functions into a new header in
TargetInfo and make users of these functions include this new header.
This fixes a layering problem.
Added:
llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.h
- copied, changed from r360721, llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp
Modified:
llvm/trunk/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp
llvm/trunk/lib/Target/BPF/BPFTargetMachine.cpp
llvm/trunk/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp
llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.h
llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp
Modified: llvm/trunk/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/AsmParser/BPFAsmParser.cpp?rev=360722&r1=360721&r2=360722&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/AsmParser/BPFAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/BPF/AsmParser/BPFAsmParser.cpp Tue May 14 15:54:06 2019
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "MCTargetDesc/BPFMCTargetDesc.h"
+#include "TargetInfo/BPFTargetInfo.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/MC/MCContext.h"
Modified: llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp?rev=360722&r1=360721&r2=360722&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp Tue May 14 15:54:06 2019
@@ -17,6 +17,7 @@
#include "BPFTargetMachine.h"
#include "BTFDebug.h"
#include "MCTargetDesc/BPFInstPrinter.h"
+#include "TargetInfo/BPFTargetInfo.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
Modified: llvm/trunk/lib/Target/BPF/BPFTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/BPFTargetMachine.cpp?rev=360722&r1=360721&r2=360722&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/BPFTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/BPF/BPFTargetMachine.cpp Tue May 14 15:54:06 2019
@@ -13,6 +13,7 @@
#include "BPFTargetMachine.h"
#include "BPF.h"
#include "MCTargetDesc/BPFMCAsmInfo.h"
+#include "TargetInfo/BPFTargetInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/CodeGen/TargetPassConfig.h"
Modified: llvm/trunk/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/Disassembler/BPFDisassembler.cpp?rev=360722&r1=360721&r2=360722&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/Disassembler/BPFDisassembler.cpp (original)
+++ llvm/trunk/lib/Target/BPF/Disassembler/BPFDisassembler.cpp Tue May 14 15:54:06 2019
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "MCTargetDesc/BPFMCTargetDesc.h"
+#include "TargetInfo/BPFTargetInfo.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
Modified: llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp?rev=360722&r1=360721&r2=360722&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp (original)
+++ llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp Tue May 14 15:54:06 2019
@@ -14,6 +14,7 @@
#include "BPF.h"
#include "MCTargetDesc/BPFInstPrinter.h"
#include "MCTargetDesc/BPFMCAsmInfo.h"
+#include "TargetInfo/BPFTargetInfo.h"
#include "llvm/MC/MCInstrAnalysis.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
Modified: llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.h?rev=360722&r1=360721&r2=360722&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.h (original)
+++ llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.h Tue May 14 15:54:06 2019
@@ -33,10 +33,6 @@ class Triple;
class raw_ostream;
class raw_pwrite_stream;
-Target &getTheBPFleTarget();
-Target &getTheBPFbeTarget();
-Target &getTheBPFTarget();
-
MCCodeEmitter *createBPFMCCodeEmitter(const MCInstrInfo &MCII,
const MCRegisterInfo &MRI,
MCContext &Ctx);
Modified: llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp?rev=360722&r1=360721&r2=360722&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp (original)
+++ llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp Tue May 14 15:54:06 2019
@@ -6,24 +6,23 @@
//
//===----------------------------------------------------------------------===//
-#include "BPF.h"
+#include "TargetInfo/BPFTargetInfo.h"
#include "llvm/Support/TargetRegistry.h"
+
using namespace llvm;
-namespace llvm {
-Target &getTheBPFleTarget() {
+Target &llvm::getTheBPFleTarget() {
static Target TheBPFleTarget;
return TheBPFleTarget;
}
-Target &getTheBPFbeTarget() {
+Target &llvm::getTheBPFbeTarget() {
static Target TheBPFbeTarget;
return TheBPFbeTarget;
}
-Target &getTheBPFTarget() {
+Target &llvm::getTheBPFTarget() {
static Target TheBPFTarget;
return TheBPFTarget;
}
-} // namespace llvm
extern "C" void LLVMInitializeBPFTargetInfo() {
TargetRegistry::RegisterTarget(getTheBPFTarget(), "bpf", "BPF (host endian)",
Copied: llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.h (from r360721, llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.h?p2=llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.h&p1=llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp&r1=360721&r2=360722&rev=360722&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp (original)
+++ llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.h Tue May 14 15:54:06 2019
@@ -1,4 +1,4 @@
-//===-- BPFTargetInfo.cpp - BPF Target Implementation ---------------------===//
+//===-- BPFTargetInfo.h - BPF Target Implementation -------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,31 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#include "BPF.h"
-#include "llvm/Support/TargetRegistry.h"
-using namespace llvm;
+#ifndef LLVM_LIB_TARGET_BPF_TARGETINFO_BPFTARGETINFO_H
+#define LLVM_LIB_TARGET_BPF_TARGETINFO_BPFTARGETINFO_H
namespace llvm {
-Target &getTheBPFleTarget() {
- static Target TheBPFleTarget;
- return TheBPFleTarget;
-}
-Target &getTheBPFbeTarget() {
- static Target TheBPFbeTarget;
- return TheBPFbeTarget;
-}
-Target &getTheBPFTarget() {
- static Target TheBPFTarget;
- return TheBPFTarget;
-}
+
+class Target;
+
+Target &getTheBPFleTarget();
+Target &getTheBPFbeTarget();
+Target &getTheBPFTarget();
+
} // namespace llvm
-extern "C" void LLVMInitializeBPFTargetInfo() {
- TargetRegistry::RegisterTarget(getTheBPFTarget(), "bpf", "BPF (host endian)",
- "BPF", [](Triple::ArchType) { return false; },
- true);
- RegisterTarget<Triple::bpfel, /*HasJIT=*/true> X(
- getTheBPFleTarget(), "bpfel", "BPF (little endian)", "BPF");
- RegisterTarget<Triple::bpfeb, /*HasJIT=*/true> Y(getTheBPFbeTarget(), "bpfeb",
- "BPF (big endian)", "BPF");
-}
+#endif // LLVM_LIB_TARGET_BPF_TARGETINFO_BPFTARGETINFO_H
More information about the llvm-commits
mailing list