Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Unified Diff: src/IceInstARM32.cpp

Issue 1424923005: Add workaround to allow testing of ARM integrated assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove unnecessary addition of ARM32 local (assembler) label. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceInstARM32.h ('k') | tests_lit/assembler/arm32/sdiv.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceInstARM32.cpp
diff --git a/src/IceInstARM32.cpp b/src/IceInstARM32.cpp
index 1697ee8c1cecf553194b361143af067037cc7e56..36445f0cee9f7d0e51e3f8e4679814b16e9e1418 100644
--- a/src/IceInstARM32.cpp
+++ b/src/IceInstARM32.cpp
@@ -61,8 +61,32 @@ const struct InstARM32CondAttributes_ {
#undef X
};
+// Holds the list of ARM assembler instructions that are safe (i.e. spec2k works
+// when these instructions are translated into bytes.
+static InstARM32::InstKindARM32 SafeIASMInsts[] = {
Jim Stichnoth 2015/11/03 00:21:42 I think a blacklist of unsafe instructions would b
Karl 2015/11/03 18:56:11 Done.
+ // TODO(kschimpf): Figure out why commented out instructions are not
+ // (always)
+ // translated correctly.
+ InstARM32::Adc, InstARM32::Add, InstARM32::And,
+ // InstARM32::Br,
+ InstARM32::Cmp, InstARM32::Eor, InstARM32::Ldr,
+ // InstARM32::Mov,
+ // InstARM32::Movw,
+ // InstARM32::Movt,
+ InstARM32::Mul, InstARM32::Orr, InstARM32::Sbc,
+ InstARM32::Sdiv, InstARM32::Str, InstARM32::Sub,
+ InstARM32::Udiv, InstARM32::Ret, InstARM32::Label};
+
} // end of anonymous namespace
+bool InstARM32::isIasSafeImpl(InstKind Kind) const {
+ for (unsigned i = 0; i < llvm::array_lengthof(SafeIASMInsts); ++i) {
Jim Stichnoth 2015/11/03 00:21:42 I realize it's only temporary, but this linear sea
Karl 2015/11/03 18:56:11 Actually, reducing the footprint by moving this to
+ if (static_cast<InstKind>(SafeIASMInsts[i]) == Kind)
+ return true;
+ }
+ return false;
+}
+
const char *InstARM32::getWidthString(Type Ty) {
return TypeARM32Attributes[Ty].WidthString;
}
@@ -345,6 +369,8 @@ void InstARM32ThreeAddrGPR<K>::emitIAS(const Cfg *Func) const {
}
template <> void InstARM32Adc::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->adc(getDest(), getSrc(0), getSrc(1), SetFlags, getPredicate());
if (Asm->needsTextFixup())
@@ -352,6 +378,8 @@ template <> void InstARM32Adc::emitIAS(const Cfg *Func) const {
}
template <> void InstARM32Add::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->add(getDest(), getSrc(0), getSrc(1), SetFlags, getPredicate());
if (Asm->needsTextFixup())
@@ -359,6 +387,8 @@ template <> void InstARM32Add::emitIAS(const Cfg *Func) const {
}
template <> void InstARM32And::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->and_(getDest(), getSrc(0), getSrc(1), SetFlags, getPredicate());
if (Asm->needsTextFixup())
@@ -366,6 +396,8 @@ template <> void InstARM32And::emitIAS(const Cfg *Func) const {
}
template <> void InstARM32Eor::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->eor(getDest(), getSrc(0), getSrc(1), SetFlags, getPredicate());
if (Asm->needsTextFixup())
@@ -373,6 +405,8 @@ template <> void InstARM32Eor::emitIAS(const Cfg *Func) const {
}
template <> void InstARM32Orr::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->orr(getDest(), getSrc(0), getSrc(1), SetFlags, getPredicate());
if (Asm->needsTextFixup())
@@ -380,6 +414,8 @@ template <> void InstARM32Orr::emitIAS(const Cfg *Func) const {
}
template <> void InstARM32Mul::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->mul(getDest(), getSrc(0), getSrc(1), SetFlags, getPredicate());
if (Asm->needsTextFixup())
@@ -387,6 +423,8 @@ template <> void InstARM32Mul::emitIAS(const Cfg *Func) const {
}
template <> void InstARM32Sbc::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->sbc(getDest(), getSrc(0), getSrc(1), SetFlags, getPredicate());
if (Asm->needsTextFixup())
@@ -394,6 +432,8 @@ template <> void InstARM32Sbc::emitIAS(const Cfg *Func) const {
}
template <> void InstARM32Sdiv::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
assert(!SetFlags);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->sdiv(getDest(), getSrc(0), getSrc(1), getPredicate());
@@ -402,6 +442,8 @@ template <> void InstARM32Sdiv::emitIAS(const Cfg *Func) const {
}
template <> void InstARM32Sub::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->sub(getDest(), getSrc(0), getSrc(1), SetFlags, getPredicate());
if (Asm->needsTextFixup())
@@ -409,6 +451,8 @@ template <> void InstARM32Sub::emitIAS(const Cfg *Func) const {
}
template <> void InstARM32Udiv::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
assert(!SetFlags);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->udiv(getDest(), getSrc(0), getSrc(1), getPredicate());
@@ -513,6 +557,8 @@ void InstARM32CmpLike<K>::emitIAS(const Cfg *Func) const {
}
template <> void InstARM32Cmp::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
assert(getSrcSize() == 2);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->cmp(getSrc(0), getSrc(1), getPredicate());
@@ -750,7 +796,8 @@ void InstARM32Mov::emit(const Cfg *Func) const {
}
void InstARM32Mov::emitIAS(const Cfg *Func) const {
- (void)Func;
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
assert(!(isMultiDest() && isMultiSource()) && "Invalid vmov type.");
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
if (!(isMultiDest() || isMultiSource())) {
@@ -803,6 +850,8 @@ void InstARM32Br::emit(const Cfg *Func) const {
}
void InstARM32Br::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
if (Label) {
Asm->b(Asm->getOrCreateLocalLabel(Label->getNumber()), getPredicate());
@@ -887,8 +936,10 @@ void InstARM32Label::emit(const Cfg *Func) const {
}
void InstARM32Label::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
- Asm->bindLocalLabel(Number);
+ Asm->bindLocalLabel(Func, this, Number);
if (Asm->needsTextFixup())
emitUsingTextFixup(Func);
}
@@ -927,6 +978,8 @@ template <> void InstARM32Ldr::emit(const Cfg *Func) const {
}
template <> void InstARM32Ldr::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
assert(getSrcSize() == 1);
Variable *Dest = getDest();
Type DestTy = Dest->getType();
@@ -984,6 +1037,8 @@ template <> void InstARM32Movw::emit(const Cfg *Func) const {
}
template <> void InstARM32Movw::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
assert(getSrcSize() == 1);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->movw(getDest(), getSrc(0), getPredicate());
@@ -1010,6 +1065,8 @@ template <> void InstARM32Movt::emit(const Cfg *Func) const {
}
template <> void InstARM32Movt::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
assert(getSrcSize() == 2);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->movt(getDest(), getSrc(1), getPredicate());
@@ -1158,6 +1215,8 @@ void InstARM32Ret::emit(const Cfg *Func) const {
}
void InstARM32Ret::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
Asm->bx(RegARM32::Encoded_Reg_lr);
if (Asm->needsTextFixup())
@@ -1191,6 +1250,8 @@ void InstARM32Str::emit(const Cfg *Func) const {
}
void InstARM32Str::emitIAS(const Cfg *Func) const {
+ if (!isIasSafe(getKind()))
+ return emitUsingTextFixup(Func);
assert(getSrcSize() == 2);
Type Ty = getSrc(0)->getType();
ARM32::AssemblerARM32 *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
« no previous file with comments | « src/IceInstARM32.h ('k') | tests_lit/assembler/arm32/sdiv.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698