[llvm] r259182 - [ARM] Emit trap instruction using .inst directive
Alexandros Lamprineas via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 29 02:23:33 PST 2016
Author: alelab01
Date: Fri Jan 29 04:23:32 2016
New Revision: 259182
URL: http://llvm.org/viewvc/llvm-project?rev=259182&view=rev
Log:
[ARM] Emit trap instruction using .inst directive
The trap instruction is emitted as a data-in-text rather
than an instruction. This patch uses the .inst directive
for emitting trap.
Differential Revision: http://reviews.llvm.org/D16684
Modified:
llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
llvm/trunk/test/CodeGen/ARM/debugtrap.ll
llvm/trunk/test/CodeGen/ARM/trap.ll
Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=259182&r1=259181&r2=259182&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Fri Jan 29 04:23:32 2016
@@ -1243,6 +1243,8 @@ void ARMAsmPrinter::EmitUnwindingInstruc
void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
const DataLayout &DL = getDataLayout();
+ MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
+ ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
// If we just ended a constant pool, mark it as such.
if (InConstantPool && MI->getOpcode() != ARM::CONSTPOOL_ENTRY) {
@@ -1659,29 +1661,26 @@ void ARMAsmPrinter::EmitInstruction(cons
// Non-Darwin binutils don't yet support the "trap" mnemonic.
// FIXME: Remove this special case when they do.
if (!Subtarget->isTargetMachO()) {
- //.long 0xe7ffdefe @ trap
uint32_t Val = 0xe7ffdefeUL;
OutStreamer->AddComment("trap");
- OutStreamer->EmitIntValue(Val, 4);
+ ATS.emitInst(Val);
return;
}
break;
}
case ARM::TRAPNaCl: {
- //.long 0xe7fedef0 @ trap
uint32_t Val = 0xe7fedef0UL;
OutStreamer->AddComment("trap");
- OutStreamer->EmitIntValue(Val, 4);
+ ATS.emitInst(Val);
return;
}
case ARM::tTRAP: {
// Non-Darwin binutils don't yet support the "trap" mnemonic.
// FIXME: Remove this special case when they do.
if (!Subtarget->isTargetMachO()) {
- //.short 57086 @ trap
uint16_t Val = 0xdefe;
OutStreamer->AddComment("trap");
- OutStreamer->EmitIntValue(Val, 2);
+ ATS.emitInst(Val, 'n');
return;
}
break;
Modified: llvm/trunk/test/CodeGen/ARM/debugtrap.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/debugtrap.ll?rev=259182&r1=259181&r2=259182&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/debugtrap.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/debugtrap.ll Fri Jan 29 04:23:32 2016
@@ -10,7 +10,7 @@ define void @test() nounwind {
entry:
; CHECK: bl foo
; CHECK-NEXT: pop
- ; CHECK-NEXT: trap
+ ; CHECK-NEXT: .inst 0xe7ffdefe
call void @foo()
call void @llvm.debugtrap()
ret void
Modified: llvm/trunk/test/CodeGen/ARM/trap.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/trap.ll?rev=259182&r1=259181&r2=259182&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/trap.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/trap.ll Fri Jan 29 04:23:32 2016
@@ -1,38 +1,56 @@
-; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s -check-prefix=INSTR
+; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s -check-prefix=DARWIN
; RUN: llc < %s -mtriple=arm-apple-darwin -trap-func=_trap | FileCheck %s -check-prefix=FUNC
; RUN: llc < %s -mtriple=arm-apple-darwin -trap-func=_trap -O0 | FileCheck %s -check-prefix=FUNC
-; RUN: llc -mtriple=armv7-unknown-nacl -filetype=obj %s -o - \
-; RUN: | llvm-objdump -disassemble -triple armv7-unknown-nacl - \
-; RUN: | FileCheck %s -check-prefix=ENCODING-NACL
-; RUN: llc -mtriple=armv7-unknown-nacl -filetype=obj %s -o - \
-; RUN: | llvm-objdump -disassemble -triple armv7 -mattr=+nacl-trap - \
-; RUN: | FileCheck %s -check-prefix=ENCODING-NACL
+; RUN: llc < %s -mtriple=armv7 -mattr=+nacl-trap | FileCheck %s -check-prefix=NACL
+; RUN: llc < %s -mtriple=armv7 | FileCheck %s -check-prefix=ARM
+; RUN: llc < %s -mtriple=thumbv7 | FileCheck %s -check-prefix=THUMB
+
; RUN: llc -mtriple=armv7 -mattr=+nacl-trap -filetype=obj %s -o - \
; RUN: | llvm-objdump -disassemble -triple armv7 -mattr=+nacl-trap - \
; RUN: | FileCheck %s -check-prefix=ENCODING-NACL
-; RUN: llc -verify-machineinstrs -fast-isel -mtriple=armv7-unknown-nacl -filetype=obj %s -o - \
-; RUN: | llvm-objdump -disassemble -triple armv7-unknown-nacl - \
+; RUN: llc -verify-machineinstrs -fast-isel -mtriple=armv7 -mattr=+nacl-trap -filetype=obj %s -o - \
+; RUN: | llvm-objdump -disassemble -triple armv7 -mattr=+nacl-trap - \
; RUN: | FileCheck %s -check-prefix=ENCODING-NACL
+
; RUN: llc -mtriple=armv7 -filetype=obj %s -o - \
; RUN: | llvm-objdump -disassemble -triple armv7 - \
-; RUN: | FileCheck %s -check-prefix=ENCODING-ALL
+; RUN: | FileCheck %s -check-prefix=ENCODING-ARM
; RUN: llc -verify-machineinstrs -fast-isel -mtriple=armv7 -filetype=obj %s -o - \
; RUN: | llvm-objdump -disassemble -triple armv7 - \
-; RUN: | FileCheck %s -check-prefix=ENCODING-ALL
+; RUN: | FileCheck %s -check-prefix=ENCODING-ARM
+
+; RUN: llc -mtriple=thumbv7 -filetype=obj %s -o - \
+; RUN: | llvm-objdump -disassemble -triple thumbv7 - \
+; RUN: | FileCheck %s -check-prefix=ENCODING-THUMB
+; RUN: llc -verify-machineinstrs -fast-isel -mtriple=thumbv7 -filetype=obj %s -o - \
+; RUN: | llvm-objdump -disassemble -triple thumbv7 - \
+; RUN: | FileCheck %s -check-prefix=ENCODING-THUMB
+
; rdar://7961298
; rdar://9249183
define void @t() nounwind {
entry:
-; INSTR-LABEL: t:
-; INSTR: trap
+; DARWIN-LABEL: t:
+; DARWIN: trap
; FUNC-LABEL: t:
; FUNC: bl __trap
-; ENCODING-NACL: f0 de fe e7
+; NACL-LABEL: t:
+; NACL: .inst 0xe7fedef0
-; ENCODING-ALL: fe de ff e7
+; ARM-LABEL: t:
+; ARM: .inst 0xe7ffdefe
+
+; THUMB-LABEL: t:
+; THUMB: .inst.n 0xdefe
+
+; ENCODING-NACL: f0 de fe e7 trap
+
+; ENCODING-ARM: fe de ff e7 trap
+
+; ENCODING-THUMB: fe de trap
call void @llvm.trap()
unreachable
@@ -40,15 +58,26 @@ entry:
define void @t2() nounwind {
entry:
-; INSTR-LABEL: t2:
-; INSTR: trap
+; DARWIN-LABEL: t2:
+; DARWIN: trap
; FUNC-LABEL: t2:
; FUNC: bl __trap
-; ENCODING-NACL: f0 de fe e7
+; NACL-LABEL: t2:
+; NACL: .inst 0xe7fedef0
+
+; ARM-LABEL: t2:
+; ARM: .inst 0xe7ffdefe
+
+; THUMB-LABEL: t2:
+; THUMB: .inst.n 0xdefe
+
+; ENCODING-NACL: f0 de fe e7 trap
+
+; ENCODING-ARM: fe de ff e7 trap
-; ENCODING-ALL: fe de ff e7
+; ENCODING-THUMB: fe de trap
call void @llvm.debugtrap()
unreachable
More information about the llvm-commits
mailing list