Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ARM] Correctly handle .inst in IT and VPT blocks #68902

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

ostannard
Copy link
Collaborator

Advance the IT and VPT block state when parsing the .inst directive, so that it is possible to use them to emit conditional instructions. If we don't do this, then a later instruction inside or just after the block will have a mis-matched condition, so be incorrectly reported as an error.

Advance the IT and VPT block state when parsing the .inst directive, so
that it is possible to use them to emit conditional instructions. If we
don't do this, then a later instruction inside or just after the block
will have a mis-matched condition, so be incorrectly reported as an
error.
@ostannard ostannard added backend:ARM mc Machine (object) code labels Oct 12, 2023
@llvmbot
Copy link

llvmbot commented Oct 12, 2023

@llvm/pr-subscribers-backend-arm

@llvm/pr-subscribers-mc

Author: None (ostannard)

Changes

Advance the IT and VPT block state when parsing the .inst directive, so that it is possible to use them to emit conditional instructions. If we don't do this, then a later instruction inside or just after the block will have a mis-matched condition, so be incorrectly reported as an error.


Full diff: https://github.com/llvm/llvm-project/pull/68902.diff

2 Files Affected:

  • (modified) llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (+2)
  • (added) llvm/test/MC/ARM/inst-directive-it-vpt.s (+26)
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index 590887b765d7f56..373d5b59bca6640 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -11981,6 +11981,8 @@ bool ARMAsmParser::parseDirectiveInst(SMLoc Loc, char Suffix) {
     }
 
     getTargetStreamer().emitInst(Value->getValue(), CurSuffix);
+    forwardITPosition();
+    forwardVPTPosition();
     return false;
   };
 
diff --git a/llvm/test/MC/ARM/inst-directive-it-vpt.s b/llvm/test/MC/ARM/inst-directive-it-vpt.s
new file mode 100644
index 000000000000000..8550d720ed42202
--- /dev/null
+++ b/llvm/test/MC/ARM/inst-directive-it-vpt.s
@@ -0,0 +1,26 @@
+// RUN: llvm-mc %s -triple armv8m.main -mattr=+mve -filetype asm -o - | FileCheck %s
+
+  .thumb
+
+// CHECK: it      eq
+// CHECK: .inst.n 0x3001
+// CHECK: add.w r0, r0, #1
+  it eq
+  .inst.n 0x3001 // addeq r0, #1
+  add r0, #1
+
+// CHECK: vpst
+// CHECK: .inst.w 0xef220844
+// CHECK: vadd.i32 q0, q1, q2
+  vpst
+  .inst.w 0xef220844 // vaddt.i32 q0, q1, q2
+  vadd.i32 q0, q1, q2
+
+// CHECK: ite eq
+// CHECK: .inst.n 0x3001
+// CHECK: addne r0, #1
+// CHECK: add.w r0, r0, #1
+  ite eq
+  .inst.n 0x3001 // addeq r0, #1
+  addne r0, #1
+  add r0, #1

@ostannard ostannard merged commit b98b567 into llvm:main Oct 12, 2023
5 checks passed
@ostannard ostannard deleted the inst_it_vpt branch October 12, 2023 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:ARM mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants