summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/BPF/InstPrinter
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2019-05-11 01:13:21 +0000
committerRichard Trieu <rtrieu@google.com>2019-05-11 01:13:21 +0000
commit48803aa65c96857fb4245cd0d74a6b422d8f8ff6 (patch)
tree512d6e1a9accd9b1e8e81d72f3fc65d03c77e939 /llvm/lib/Target/BPF/InstPrinter
parentbf9e67b5b973e9e910747807bd9c7aad97617e2c (diff)
downloadbcm5719-llvm-48803aa65c96857fb4245cd0d74a6b422d8f8ff6.tar.gz
bcm5719-llvm-48803aa65c96857fb4245cd0d74a6b422d8f8ff6.zip
[BPF] Move InstPrinter files to MCTargetDesc. NFC
For some targets, there is a circular dependency between InstPrinter and MCTargetDesc. Merging them together will fix this. For the other targets, the merging is to maintain consistency so all targets will have the same structure. llvm-svn: 360494
Diffstat (limited to 'llvm/lib/Target/BPF/InstPrinter')
-rw-r--r--llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp107
-rw-r--r--llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.h40
-rw-r--r--llvm/lib/Target/BPF/InstPrinter/CMakeLists.txt3
-rw-r--r--llvm/lib/Target/BPF/InstPrinter/LLVMBuild.txt22
4 files changed, 0 insertions, 172 deletions
diff --git a/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp b/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp
deleted file mode 100644
index 91411a745d7..00000000000
--- a/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-//===-- BPFInstPrinter.cpp - Convert BPF MCInst to asm syntax -------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This class prints an BPF MCInst to a .s file.
-//
-//===----------------------------------------------------------------------===//
-
-#include "BPFInstPrinter.h"
-#include "llvm/MC/MCAsmInfo.h"
-#include "llvm/MC/MCExpr.h"
-#include "llvm/MC/MCInst.h"
-#include "llvm/MC/MCSymbol.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/FormattedStream.h"
-using namespace llvm;
-
-#define DEBUG_TYPE "asm-printer"
-
-// Include the auto-generated portion of the assembly writer.
-#include "BPFGenAsmWriter.inc"
-
-void BPFInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
- StringRef Annot, const MCSubtargetInfo &STI) {
- printInstruction(MI, O);
- printAnnotation(O, Annot);
-}
-
-static void printExpr(const MCExpr *Expr, raw_ostream &O) {
-#ifndef NDEBUG
- const MCSymbolRefExpr *SRE;
-
- if (const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(Expr))
- SRE = dyn_cast<MCSymbolRefExpr>(BE->getLHS());
- else
- SRE = dyn_cast<MCSymbolRefExpr>(Expr);
- assert(SRE && "Unexpected MCExpr type.");
-
- MCSymbolRefExpr::VariantKind Kind = SRE->getKind();
-
- assert(Kind == MCSymbolRefExpr::VK_None);
-#endif
- O << *Expr;
-}
-
-void BPFInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
- raw_ostream &O, const char *Modifier) {
- assert((Modifier == 0 || Modifier[0] == 0) && "No modifiers supported");
- const MCOperand &Op = MI->getOperand(OpNo);
- if (Op.isReg()) {
- O << getRegisterName(Op.getReg());
- } else if (Op.isImm()) {
- O << formatImm((int32_t)Op.getImm());
- } else {
- assert(Op.isExpr() && "Expected an expression");
- printExpr(Op.getExpr(), O);
- }
-}
-
-void BPFInstPrinter::printMemOperand(const MCInst *MI, int OpNo, raw_ostream &O,
- const char *Modifier) {
- const MCOperand &RegOp = MI->getOperand(OpNo);
- const MCOperand &OffsetOp = MI->getOperand(OpNo + 1);
-
- // register
- assert(RegOp.isReg() && "Register operand not a register");
- O << getRegisterName(RegOp.getReg());
-
- // offset
- if (OffsetOp.isImm()) {
- auto Imm = OffsetOp.getImm();
- if (Imm >= 0)
- O << " + " << formatImm(Imm);
- else
- O << " - " << formatImm(-Imm);
- } else {
- assert(0 && "Expected an immediate");
- }
-}
-
-void BPFInstPrinter::printImm64Operand(const MCInst *MI, unsigned OpNo,
- raw_ostream &O) {
- const MCOperand &Op = MI->getOperand(OpNo);
- if (Op.isImm())
- O << formatImm(Op.getImm());
- else if (Op.isExpr())
- printExpr(Op.getExpr(), O);
- else
- O << Op;
-}
-
-void BPFInstPrinter::printBrTargetOperand(const MCInst *MI, unsigned OpNo,
- raw_ostream &O) {
- const MCOperand &Op = MI->getOperand(OpNo);
- if (Op.isImm()) {
- int16_t Imm = Op.getImm();
- O << ((Imm >= 0) ? "+" : "") << formatImm(Imm);
- } else if (Op.isExpr()) {
- printExpr(Op.getExpr(), O);
- } else {
- O << Op;
- }
-}
diff --git a/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.h b/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.h
deleted file mode 100644
index 3472423c466..00000000000
--- a/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.h
+++ /dev/null
@@ -1,40 +0,0 @@
-//===-- BPFInstPrinter.h - Convert BPF MCInst to asm syntax -------*- C++ -*--//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This class prints a BPF MCInst to a .s file.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_TARGET_BPF_INSTPRINTER_BPFINSTPRINTER_H
-#define LLVM_LIB_TARGET_BPF_INSTPRINTER_BPFINSTPRINTER_H
-
-#include "llvm/MC/MCInstPrinter.h"
-
-namespace llvm {
-class BPFInstPrinter : public MCInstPrinter {
-public:
- BPFInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
- const MCRegisterInfo &MRI)
- : MCInstPrinter(MAI, MII, MRI) {}
-
- void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
- const MCSubtargetInfo &STI) override;
- void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O,
- const char *Modifier = nullptr);
- void printMemOperand(const MCInst *MI, int OpNo, raw_ostream &O,
- const char *Modifier = nullptr);
- void printImm64Operand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
- void printBrTargetOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
-
- // Autogenerated by tblgen.
- void printInstruction(const MCInst *MI, raw_ostream &O);
- static const char *getRegisterName(unsigned RegNo);
-};
-}
-
-#endif
diff --git a/llvm/lib/Target/BPF/InstPrinter/CMakeLists.txt b/llvm/lib/Target/BPF/InstPrinter/CMakeLists.txt
deleted file mode 100644
index f9e91619252..00000000000
--- a/llvm/lib/Target/BPF/InstPrinter/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-add_llvm_library(LLVMBPFAsmPrinter
- BPFInstPrinter.cpp
- )
diff --git a/llvm/lib/Target/BPF/InstPrinter/LLVMBuild.txt b/llvm/lib/Target/BPF/InstPrinter/LLVMBuild.txt
deleted file mode 100644
index 6a5b3f546c8..00000000000
--- a/llvm/lib/Target/BPF/InstPrinter/LLVMBuild.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-;===- ./lib/Target/BPF/InstPrinter/LLVMBuild.txt ---------------*- Conf -*--===;
-;
-; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-; See https://llvm.org/LICENSE.txt for license information.
-; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-;
-;===------------------------------------------------------------------------===;
-;
-; This is an LLVMBuild description file for the components in this subdirectory.
-;
-; For more information on the LLVMBuild system, please see:
-;
-; http://llvm.org/docs/LLVMBuild.html
-;
-;===------------------------------------------------------------------------===;
-
-[component_0]
-type = Library
-name = BPFAsmPrinter
-parent = BPF
-required_libraries = MC Support
-add_to_library_groups = BPF
OpenPOWER on IntegriCloud