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

Unified Diff: src/IceInstX8632.cpp

Issue 321993002: Add a few Subzero intrinsics (not the atomic ones yet). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: remove TODO Created 6 years, 6 months 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/IceInstX8632.h ('k') | src/IceInstX8632.def » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceInstX8632.cpp
diff --git a/src/IceInstX8632.cpp b/src/IceInstX8632.cpp
index 17e571271de0f749092b0372625831a231a79d21..647768341dbab3b795e466b7be2125f7917a413b 100644
--- a/src/IceInstX8632.cpp
+++ b/src/IceInstX8632.cpp
@@ -50,6 +50,15 @@ const struct TypeX8632Attributes_ {
const size_t TypeX8632AttributesSize =
llvm::array_lengthof(TypeX8632Attributes);
+const char *InstX8632SegmentRegNames[] = {
+#define X(val, name) \
+ name,
+ SEG_REGX8632_TABLE
+#undef X
+};
+const size_t InstX8632SegmentRegNamesSize =
+ llvm::array_lengthof(InstX8632SegmentRegNames);
+
} // end of anonymous namespace
const char *InstX8632::getWidthString(Type Ty) {
@@ -58,9 +67,9 @@ const char *InstX8632::getWidthString(Type Ty) {
OperandX8632Mem::OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base,
Constant *Offset, Variable *Index,
- uint32_t Shift)
+ uint16_t Shift, SegmentRegisters SegmentReg)
: OperandX8632(kMem, Ty), Base(Base), Offset(Offset), Index(Index),
- Shift(Shift) {
+ Shift(Shift), SegmentReg(SegmentReg) {
assert(Shift <= 3);
Vars = NULL;
NumVars = 0;
@@ -148,6 +157,9 @@ InstX8632Ucomiss::InstX8632Ucomiss(Cfg *Func, Operand *Src0, Operand *Src1)
addSource(Src1);
}
+InstX8632UD2::InstX8632UD2(Cfg *Func)
+ : InstX8632(Func, InstX8632::UD2, 0, NULL) {}
+
InstX8632Test::InstX8632Test(Cfg *Func, Operand *Src1, Operand *Src2)
: InstX8632(Func, InstX8632::Test, 2, NULL) {
addSource(Src1);
@@ -525,6 +537,17 @@ void InstX8632Ucomiss::dump(const Cfg *Func) const {
dumpSources(Func);
}
+void InstX8632UD2::emit(const Cfg *Func) const {
+ Ostream &Str = Func->getContext()->getStrEmit();
+ assert(getSrcSize() == 0);
+ Str << "\tud2\n";
+}
+
+void InstX8632UD2::dump(const Cfg *Func) const {
+ Ostream &Str = Func->getContext()->getStrDump();
+ Str << "ud2\n";
+}
+
void InstX8632Test::emit(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
@@ -758,6 +781,11 @@ void OperandX8632::dump(const Cfg *Func) const {
void OperandX8632Mem::emit(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit();
Str << TypeX8632Attributes[getType()].WidthString << " ";
+ if (SegmentReg != DefaultSegment) {
+ assert(SegmentReg >= 0 &&
+ static_cast<size_t>(SegmentReg) < InstX8632SegmentRegNamesSize);
+ Str << InstX8632SegmentRegNames[SegmentReg] << ":";
+ }
// TODO: The following is an almost verbatim paste of dump().
bool Dumped = false;
Str << "[";
@@ -782,11 +810,14 @@ void OperandX8632Mem::emit(const Cfg *Func) const {
OffsetIsZero = (CI->getValue() == 0);
OffsetIsNegative = (static_cast<int64_t>(CI->getValue()) < 0);
}
- if (!OffsetIsZero) { // Suppress if Offset is known to be 0
- if (Dumped) {
+ if (Dumped) {
+ if (!OffsetIsZero) { // Suppress if Offset is known to be 0
if (!OffsetIsNegative) // Suppress if Offset is known to be negative
Str << "+";
+ Offset->emit(Func);
}
+ } else {
+ // There is only the offset.
Offset->emit(Func);
}
Str << "]";
@@ -794,6 +825,11 @@ void OperandX8632Mem::emit(const Cfg *Func) const {
void OperandX8632Mem::dump(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrDump();
+ if (SegmentReg != DefaultSegment) {
+ assert(SegmentReg >= 0 &&
+ static_cast<size_t>(SegmentReg) < InstX8632SegmentRegNamesSize);
+ Str << InstX8632SegmentRegNames[SegmentReg] << ":";
+ }
bool Dumped = false;
Str << "[";
if (Base) {
@@ -817,11 +853,14 @@ void OperandX8632Mem::dump(const Cfg *Func) const {
OffsetIsZero = (CI->getValue() == 0);
OffsetIsNegative = (static_cast<int64_t>(CI->getValue()) < 0);
}
- if (!OffsetIsZero) { // Suppress if Offset is known to be 0
- if (Dumped) {
+ if (Dumped) {
+ if (!OffsetIsZero) { // Suppress if Offset is known to be 0
if (!OffsetIsNegative) // Suppress if Offset is known to be negative
Str << "+";
+ Offset->dump(Func);
}
+ } else {
+ // There is only the offset.
Offset->dump(Func);
}
Str << "]";
« no previous file with comments | « src/IceInstX8632.h ('k') | src/IceInstX8632.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698