[llvm] r310059 - [AMDGPU][MC] Enabled expressions as operands

Dmitry Preobrazhensky via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 06:55:24 PDT 2017


Author: dpreobra
Date: Fri Aug  4 06:55:24 2017
New Revision: 310059

URL: http://llvm.org/viewvc/llvm-project?rev=310059&view=rev
Log:
[AMDGPU][MC] Enabled expressions as operands

See bug 33579: https://bugs.llvm.org//show_bug.cgi?id=33579

Reviewers: vpykhtin, SamWot, arsenm

Differential Revision: https://reviews.llvm.org/D36091

Modified:
    llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
    llvm/trunk/test/MC/AMDGPU/expressions.s
    llvm/trunk/test/MC/AMDGPU/vop3p-err.s

Modified: llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp?rev=310059&r1=310058&r2=310059&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp Fri Aug  4 06:55:24 2017
@@ -2530,24 +2530,22 @@ AMDGPUAsmParser::parseOperand(OperandVec
   if (ResTy == MatchOperand_Success)
     return ResTy;
 
-  if (getLexer().getKind() == AsmToken::Identifier) {
-    // If this identifier is a symbol, we want to create an expression for it.
-    // It is a little difficult to distinguish between a symbol name, and
-    // an instruction flag like 'gds'.  In order to do this, we parse
-    // all tokens as expressions and then treate the symbol name as the token
-    // string when we want to interpret the operand as a token.
-    const auto &Tok = Parser.getTok();
-    SMLoc S = Tok.getLoc();
-    const MCExpr *Expr = nullptr;
-    if (!Parser.parseExpression(Expr)) {
-      Operands.push_back(AMDGPUOperand::CreateExpr(this, Expr, S));
-      return MatchOperand_Success;
-    }
+  const auto &Tok = Parser.getTok();
+  SMLoc S = Tok.getLoc();
 
-    Operands.push_back(AMDGPUOperand::CreateToken(this, Tok.getString(), Tok.getLoc()));
+  const MCExpr *Expr = nullptr;
+  if (!Parser.parseExpression(Expr)) {
+    Operands.push_back(AMDGPUOperand::CreateExpr(this, Expr, S));
+    return MatchOperand_Success;
+  }
+
+  // Possibly this is an instruction flag like 'gds'.
+  if (Tok.getKind() == AsmToken::Identifier) {
+    Operands.push_back(AMDGPUOperand::CreateToken(this, Tok.getString(), S));
     Parser.Lex();
     return MatchOperand_Success;
   }
+
   return MatchOperand_NoMatch;
 }
 

Modified: llvm/trunk/test/MC/AMDGPU/expressions.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AMDGPU/expressions.s?rev=310059&r1=310058&r2=310059&view=diff
==============================================================================
--- llvm/trunk/test/MC/AMDGPU/expressions.s (original)
+++ llvm/trunk/test/MC/AMDGPU/expressions.s Fri Aug  4 06:55:24 2017
@@ -39,3 +39,10 @@ s_mov_b32 s0, foo+2
 .set foo, 512
 s_mov_b32 s0, foo+2
 // VI: s_mov_b32 s0, 514 ; encoding: [0xff,0x00,0x80,0xbe,0x02,0x02,0x00,0x00]
+
+BB1:
+v_nop_e64
+BB2:
+s_sub_u32 vcc_lo, vcc_lo, (BB2+4)-BB1
+// VI: s_sub_u32 vcc_lo, vcc_lo, (BB2+4)-BB1 ; encoding: [0x6a,0xff,0xea,0x80,A,A,A,A]
+// VI-NEXT: ;   fixup A - offset: 4, value: (BB2+4)-BB1, kind: FK_Data_4

Modified: llvm/trunk/test/MC/AMDGPU/vop3p-err.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AMDGPU/vop3p-err.s?rev=310059&r1=310058&r2=310059&view=diff
==============================================================================
--- llvm/trunk/test/MC/AMDGPU/vop3p-err.s (original)
+++ llvm/trunk/test/MC/AMDGPU/vop3p-err.s Fri Aug  4 06:55:24 2017
@@ -50,13 +50,13 @@ v_pk_add_u16 v1, v2, v3 neg_lo:[0,0]
 // GFX9: :18: error: not a valid operand.
 v_pk_add_f16 v1, |v2|, v3
 
-// GFX9: :21: error: not a valid operand.
+// GFX9: :18: error: invalid operand for instruction
 v_pk_add_f16 v1, abs(v2), v3
 
 // GFX9: :22: error: not a valid operand.
 v_pk_add_f16 v1, v2, |v3|
 
-// GFX9: :25: error: not a valid operand.
+// GFX9: :22: error: invalid operand for instruction
 v_pk_add_f16 v1, v2, abs(v3)
 
 // GFX9: :19: error: invalid operand for instruction
@@ -65,7 +65,7 @@ v_pk_add_f16 v1, -v2, v3
 // GFX9: :23: error: invalid operand for instruction
 v_pk_add_f16 v1, v2, -v3
 
-// GFX9: :21: error: not a valid operand.
+// GFX9: :18: error: invalid operand for instruction
 v_pk_add_u16 v1, abs(v2), v3
 
 // GFX9: :19: error: invalid operand for instruction




More information about the llvm-commits mailing list