OSDN Git Service

Fix skip_unimplemented for filetype=obj in ARM.
authorKarl Schimpf <kschimpf@google.com>
Tue, 2 Feb 2016 18:17:01 +0000 (10:17 -0800)
committerKarl Schimpf <kschimpf@google.com>
Tue, 2 Feb 2016 18:17:01 +0000 (10:17 -0800)
Fixes generation of emit text fixup code in integrated ARM assembler to
properly reset the text fixup flag when skipping unimplemented
instructions.

Also fixes broken assertion for the "vmul" instruction.

BUG=None
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1656023002 .

src/IceAssembler.cpp
src/IceAssembler.h
src/IceInstARM32.cpp

index 44c4ee2..28851f9 100644 (file)
@@ -66,7 +66,7 @@ AssemblerTextFixup *AssemblerBuffer::createTextFixup(const std::string &Text,
   AssemblerTextFixup *F = new (Assemblr.allocate<AssemblerTextFixup>())
       AssemblerTextFixup(Text, BytesUsed);
   installFixup(F);
-  TextFixupNeeded = false;
+  resetNeedsTextFixup();
   return F;
 }
 
index d3111ad..5c8091d 100644 (file)
@@ -184,6 +184,7 @@ public:
   /// Mark that an attempt was made to emit, but failed. Hence, in order to
   /// continue, one must emit a text fixup.
   void setNeedsTextFixup() { TextFixupNeeded = true; }
+  void resetNeedsTextFixup() { TextFixupNeeded = false; }
 
   /// Returns true if last emit failed and needs a text fixup.
   bool needsTextFixup() const { return TextFixupNeeded; }
@@ -310,6 +311,7 @@ public:
   }
 
   void setNeedsTextFixup() { Buffer.setNeedsTextFixup(); }
+  void resetNeedsTextFixup() { Buffer.resetNeedsTextFixup(); }
 
   bool needsTextFixup() const { return Buffer.needsTextFixup(); }
 
index 23216a0..7189c02 100644 (file)
@@ -98,6 +98,12 @@ void InstARM32::emitUsingTextFixup(const Cfg *Func) const {
     return;
   GlobalContext *Ctx = Func->getContext();
   auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
+  if (Ctx->getFlags().getDisableHybridAssembly() &&
+      Ctx->getFlags().getSkipUnimplemented()) {
+    Asm->trap();
+    Asm->resetNeedsTextFixup();
+    return;
+  }
   std::string Buffer;
   llvm::raw_string_ostream StrBuf(Buffer);
   OstreamLocker L(Ctx);
@@ -116,6 +122,7 @@ void InstARM32::emitUsingTextFixup(const Cfg *Func) const {
       llvm::errs() << "Can't assemble: " << StrBuf.str() << "\n";
       UnimplementedError(Ctx->getFlags());
     }
+    Asm->resetNeedsTextFixup();
     return;
   }
   Asm->emitTextInst(StrBuf.str(), Asm->getEmitTextSize());
@@ -751,17 +758,16 @@ template <> void InstARM32Vmul::emitIAS(const Cfg *Func) const {
   default:
     // TODO(kschimpf) Figure if more cases are needed.
     emitUsingTextFixup(Func);
-    break;
+    return;
   case IceType_f32:
     Asm->vmuls(getDest(), getSrc(0), getSrc(1), CondARM32::AL);
     assert(!Asm->needsTextFixup());
-    break;
+    return;
   case IceType_f64:
     Asm->vmuld(getDest(), getSrc(0), getSrc(1), CondARM32::AL);
     assert(!Asm->needsTextFixup());
-    break;
+    return;
   }
-  assert(!Asm->needsTextFixup());
 }
 
 InstARM32Call::InstARM32Call(Cfg *Func, Variable *Dest, Operand *CallTarget)