summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/InstPrinter
diff options
context:
space:
mode:
authorArtem Tamazov <artem.tamazov@amd.com>2016-05-26 17:00:33 +0000
committerArtem Tamazov <artem.tamazov@amd.com>2016-05-26 17:00:33 +0000
commit6edc135d0f4e4a5636bf0707971b6e619d5dc0c6 (patch)
treeec2434e2e87221ada903bb03c00c9cfa8a02757f /llvm/lib/Target/AMDGPU/InstPrinter
parentd486f84c579d7365be3d64c48a4cf1138b483818 (diff)
downloadbcm5719-llvm-6edc135d0f4e4a5636bf0707971b6e619d5dc0c6.tar.gz
bcm5719-llvm-6edc135d0f4e4a5636bf0707971b6e619d5dc0c6.zip
[AMDGPU][llvm-mc] s_getreg/setreg* - hwreg - factor out strings/literals etc.
Hwreg(...) syntax implementation unified with sendmsg(...). Common strings moved to Utils MathExtras.h functionality utilized. Added missing build dependency in Disassembler. Differential Revision: http://reviews.llvm.org/D20381 llvm-svn: 270871
Diffstat (limited to 'llvm/lib/Target/AMDGPU/InstPrinter')
-rw-r--r--llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp74
-rw-r--r--llvm/lib/Target/AMDGPU/InstPrinter/CMakeLists.txt2
-rw-r--r--llvm/lib/Target/AMDGPU/InstPrinter/LLVMBuild.txt2
3 files changed, 15 insertions, 63 deletions
diff --git a/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp b/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp
index d67f4951bd4..ba1175c5cab 100644
--- a/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp
@@ -11,6 +11,7 @@
#include "AMDGPUInstPrinter.h"
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
#include "SIDefines.h"
+#include "Utils/AMDGPUAsmUtils.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrInfo.h"
@@ -20,54 +21,6 @@
#include <string>
-// FIXME ODR: Move this to some common place for AsmParser and InstPrinter
-namespace llvm {
-namespace AMDGPU {
-namespace SendMsg {
-
-// This must be in sync with llvm::AMDGPU::SendMsg::Id enum members.
-static
-const char* const IdSymbolic[] = {
- nullptr,
- "MSG_INTERRUPT",
- "MSG_GS",
- "MSG_GS_DONE",
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- "MSG_SYSMSG"
-};
-
-// These two must be in sync with llvm::AMDGPU::SendMsg::Op enum members.
-static
-const char* const OpSysSymbolic[] = {
- nullptr,
- "SYSMSG_OP_ECC_ERR_INTERRUPT",
- "SYSMSG_OP_REG_RD",
- "SYSMSG_OP_HOST_TRAP_ACK",
- "SYSMSG_OP_TTRACE_PC"
-};
-
-static
-const char* const OpGsSymbolic[] = {
- "GS_OP_NOP",
- "GS_OP_CUT",
- "GS_OP_EMIT",
- "GS_OP_EMIT_CUT"
-};
-
-} // namespace SendMsg
-} // namespace AMDGPU
-} // namespace llvm
-
using namespace llvm;
void AMDGPUInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
@@ -886,23 +839,20 @@ void AMDGPUInstPrinter::printWaitFlag(const MCInst *MI, unsigned OpNo,
void AMDGPUInstPrinter::printHwreg(const MCInst *MI, unsigned OpNo,
raw_ostream &O) {
+ using namespace llvm::AMDGPU::Hwreg;
+
unsigned SImm16 = MI->getOperand(OpNo).getImm();
- const unsigned HwRegCode = SImm16 & 0x3F;
- const unsigned Offset = (SImm16 >> 6) & 0x1f;
- const unsigned Width = ((SImm16 >> 11) & 0x1F) + 1;
+ const unsigned Id = (SImm16 & ID_MASK_) >> ID_SHIFT_;
+ const unsigned Offset = (SImm16 & OFFSET_MASK_) >> OFFSET_SHIFT_;
+ const unsigned Width = ((SImm16 & WIDTH_M1_MASK_) >> WIDTH_M1_SHIFT_) + 1;
O << "hwreg(";
- switch(HwRegCode) {
- case 1: O << "HW_REG_MODE" ; break;
- case 2: O << "HW_REG_STATUS" ; break;
- case 3: O << "HW_REG_TRAPSTS" ; break;
- case 4: O << "HW_REG_HW_ID" ; break;
- case 5: O << "HW_REG_GPR_ALLOC" ; break;
- case 6: O << "HW_REG_LDS_ALLOC" ; break;
- case 7: O << "HW_REG_IB_STS" ; break;
- default: O << HwRegCode; break;
- }
- if (! (Width == 32 && Offset == 0)) {
+ if (ID_SYMBOLIC_FIRST_ <= Id && Id < ID_SYMBOLIC_LAST_) {
+ O << IdSymbolic[Id];
+ } else {
+ O << Id;
+ }
+ if (Width != WIDTH_M1_DEFAULT_ + 1 || Offset != OFFSET_DEFAULT_) {
O << ", " << Offset << ", " << Width;
}
O << ')';
diff --git a/llvm/lib/Target/AMDGPU/InstPrinter/CMakeLists.txt b/llvm/lib/Target/AMDGPU/InstPrinter/CMakeLists.txt
index ce63bd553b9..7191ff2c457 100644
--- a/llvm/lib/Target/AMDGPU/InstPrinter/CMakeLists.txt
+++ b/llvm/lib/Target/AMDGPU/InstPrinter/CMakeLists.txt
@@ -1,3 +1,5 @@
add_llvm_library(LLVMAMDGPUAsmPrinter
AMDGPUInstPrinter.cpp
)
+
+add_dependencies(LLVMAMDGPUAsmPrinter LLVMAMDGPUUtils)
diff --git a/llvm/lib/Target/AMDGPU/InstPrinter/LLVMBuild.txt b/llvm/lib/Target/AMDGPU/InstPrinter/LLVMBuild.txt
index fdb43844dc6..30c2670316c 100644
--- a/llvm/lib/Target/AMDGPU/InstPrinter/LLVMBuild.txt
+++ b/llvm/lib/Target/AMDGPU/InstPrinter/LLVMBuild.txt
@@ -19,6 +19,6 @@
type = Library
name = AMDGPUAsmPrinter
parent = AMDGPU
-required_libraries = MC Support
+required_libraries = MC Support AMDGPUUtils
add_to_library_groups = AMDGPU
OpenPOWER on IntegriCloud