[llvm] r360732 - [RISCV] Create a TargetInfo header. NFC
Richard Trieu via llvm-commits
llvm-commits at lists.llvm.org
Tue May 14 17:24:15 PDT 2019
Author: rtrieu
Date: Tue May 14 17:24:15 2019
New Revision: 360732
URL: http://llvm.org/viewvc/llvm-project?rev=360732&view=rev
Log:
[RISCV] 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/RISCV/TargetInfo/RISCVTargetInfo.h
- copied, changed from r360731, llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp
Modified:
llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.h
llvm/trunk/lib/Target/RISCV/RISCVAsmPrinter.cpp
llvm/trunk/lib/Target/RISCV/RISCVTargetMachine.cpp
llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp
Modified: llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp?rev=360732&r1=360731&r2=360732&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp Tue May 14 17:24:15 2019
@@ -10,6 +10,7 @@
#include "MCTargetDesc/RISCVMCExpr.h"
#include "MCTargetDesc/RISCVMCTargetDesc.h"
#include "MCTargetDesc/RISCVTargetStreamer.h"
+#include "TargetInfo/RISCVTargetInfo.h"
#include "Utils/RISCVBaseInfo.h"
#include "Utils/RISCVMatInt.h"
#include "llvm/ADT/STLExtras.h"
Modified: llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp?rev=360732&r1=360731&r2=360732&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp Tue May 14 17:24:15 2019
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "MCTargetDesc/RISCVMCTargetDesc.h"
+#include "TargetInfo/RISCVTargetInfo.h"
#include "Utils/RISCVBaseInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
Modified: llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp?rev=360732&r1=360731&r2=360732&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp Tue May 14 17:24:15 2019
@@ -15,6 +15,7 @@
#include "RISCVInstPrinter.h"
#include "RISCVMCAsmInfo.h"
#include "RISCVTargetStreamer.h"
+#include "TargetInfo/RISCVTargetInfo.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCInstrInfo.h"
Modified: llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.h?rev=360732&r1=360731&r2=360732&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.h (original)
+++ llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.h Tue May 14 17:24:15 2019
@@ -32,9 +32,6 @@ class Triple;
class raw_ostream;
class raw_pwrite_stream;
-Target &getTheRISCV32Target();
-Target &getTheRISCV64Target();
-
MCCodeEmitter *createRISCVMCCodeEmitter(const MCInstrInfo &MCII,
const MCRegisterInfo &MRI,
MCContext &Ctx);
Modified: llvm/trunk/lib/Target/RISCV/RISCVAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/RISCVAsmPrinter.cpp?rev=360732&r1=360731&r2=360732&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/RISCVAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/RISCVAsmPrinter.cpp Tue May 14 17:24:15 2019
@@ -15,6 +15,7 @@
#include "MCTargetDesc/RISCVInstPrinter.h"
#include "MCTargetDesc/RISCVMCExpr.h"
#include "RISCVTargetMachine.h"
+#include "TargetInfo/RISCVTargetInfo.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
Modified: llvm/trunk/lib/Target/RISCV/RISCVTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/RISCVTargetMachine.cpp?rev=360732&r1=360731&r2=360732&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/RISCVTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/RISCVTargetMachine.cpp Tue May 14 17:24:15 2019
@@ -13,6 +13,7 @@
#include "RISCV.h"
#include "RISCVTargetMachine.h"
#include "RISCVTargetObjectFile.h"
+#include "TargetInfo/RISCVTargetInfo.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
Modified: llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp?rev=360732&r1=360731&r2=360732&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp Tue May 14 17:24:15 2019
@@ -6,20 +6,19 @@
//
//===----------------------------------------------------------------------===//
+#include "TargetInfo/RISCVTargetInfo.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
-namespace llvm {
-Target &getTheRISCV32Target() {
+Target &llvm::getTheRISCV32Target() {
static Target TheRISCV32Target;
return TheRISCV32Target;
}
-Target &getTheRISCV64Target() {
+Target &llvm::getTheRISCV64Target() {
static Target TheRISCV64Target;
return TheRISCV64Target;
}
-}
extern "C" void LLVMInitializeRISCVTargetInfo() {
RegisterTarget<Triple::riscv32> X(getTheRISCV32Target(), "riscv32",
Copied: llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.h (from r360731, llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.h?p2=llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.h&p1=llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp&r1=360731&r2=360732&rev=360732&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.h Tue May 14 17:24:15 2019
@@ -1,4 +1,4 @@
-//===-- RISCVTargetInfo.cpp - RISCV Target Implementation -----------------===//
+//===-- RISCVTargetInfo.h - RISCV 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,24 +6,16 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Support/TargetRegistry.h"
-using namespace llvm;
+#ifndef LLVM_LIB_TARGET_RISCV_TARGETINFO_RISCVTARGETINFO_H
+#define LLVM_LIB_TARGET_RISCV_TARGETINFO_RISCVTARGETINFO_H
namespace llvm {
-Target &getTheRISCV32Target() {
- static Target TheRISCV32Target;
- return TheRISCV32Target;
-}
-
-Target &getTheRISCV64Target() {
- static Target TheRISCV64Target;
- return TheRISCV64Target;
-}
-}
-
-extern "C" void LLVMInitializeRISCVTargetInfo() {
- RegisterTarget<Triple::riscv32> X(getTheRISCV32Target(), "riscv32",
- "32-bit RISC-V", "RISCV");
- RegisterTarget<Triple::riscv64> Y(getTheRISCV64Target(), "riscv64",
- "64-bit RISC-V", "RISCV");
-}
+
+class Target;
+
+Target &getTheRISCV32Target();
+Target &getTheRISCV64Target();
+
+} // namespace llvm
+
+#endif // LLVM_LIB_TARGET_RISCV_TARGETINFO_RISCVTARGETINFO_H
More information about the llvm-commits
mailing list