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

Unified Diff: src/IceInstMIPS32.cpp

Issue 2504253002: [Subzero][MIPS] Implements atomic intrinsics for MIPS32 (Closed)
Patch Set: Created 4 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
Index: src/IceInstMIPS32.cpp
diff --git a/src/IceInstMIPS32.cpp b/src/IceInstMIPS32.cpp
index b627a201f16dca7fe00eb7b7b43733e89b6650d6..1e58a85429d60ab66b55c44b2511fe959a5b36f4 100644
--- a/src/IceInstMIPS32.cpp
+++ b/src/IceInstMIPS32.cpp
@@ -97,6 +97,7 @@ template <> const char *InstMIPS32Div_s::Opcode = "div.s";
template <> const char *InstMIPS32Divu::Opcode = "divu";
template <> const char *InstMIPS32La::Opcode = "la";
template <> const char *InstMIPS32Ldc1::Opcode = "ldc1";
+template <> const char *InstMIPS32Ll::Opcode = "ll";
template <> const char *InstMIPS32Lui::Opcode = "lui";
template <> const char *InstMIPS32Lw::Opcode = "lw";
template <> const char *InstMIPS32Lwc1::Opcode = "lwc1";
@@ -124,6 +125,7 @@ template <> const char *InstMIPS32Multu::Opcode = "multu";
template <> const char *InstMIPS32Nor::Opcode = "nor";
template <> const char *InstMIPS32Or::Opcode = "or";
template <> const char *InstMIPS32Ori::Opcode = "ori";
+template <> const char *InstMIPS32Sc::Opcode = "sc";
template <> const char *InstMIPS32Sdc1::Opcode = "sdc1";
template <> const char *InstMIPS32Sll::Opcode = "sll";
template <> const char *InstMIPS32Sllv::Opcode = "sllv";
@@ -429,8 +431,12 @@ void InstMIPS32Br::emitIAS(const Cfg *Func) const {
auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
if (Label != nullptr) {
// Intra-block branches are of kind bcc
- Asm->bcc(Predicate, getSrc(0), getSrc(1),
- Asm->getOrCreateLocalLabel(Label->getNumber()));
+ if (isUnconditionalBranch()) {
+ Asm->b(Asm->getOrCreateLocalLabel(Label->getNumber()));
+ } else {
+ Asm->bcc(Predicate, getSrc(0), getSrc(1),
+ Asm->getOrCreateLocalLabel(Label->getNumber()));
+ }
} else if (isUnconditionalBranch()) {
Asm->b(Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex()));
} else {
@@ -465,10 +471,14 @@ void InstMIPS32Br::emit(const Cfg *Func) const {
Str << "\t"
"b" << InstMIPS32CondAttributes[Predicate].EmitString << "\t";
if (Label != nullptr) {
- getSrc(0)->emit(Func);
- Str << ", ";
- getSrc(1)->emit(Func);
- Str << ", " << Label->getLabelName();
+ if (isUnconditionalBranch()) {
+ Str << Label->getLabelName();
+ } else {
+ getSrc(0)->emit(Func);
+ Str << ", ";
+ getSrc(1)->emit(Func);
+ Str << ", " << Label->getLabelName();
+ }
} else {
if (isUnconditionalBranch()) {
Str << getTargetFalse()->getAsmName();
@@ -513,10 +523,14 @@ void InstMIPS32Br::dump(const Cfg *Func) const {
"b" << InstMIPS32CondAttributes[Predicate].EmitString << "\t";
if (Label != nullptr) {
- getSrc(0)->dump(Func);
- Str << ", ";
- getSrc(1)->dump(Func);
- Str << ", " << Label->getLabelName();
+ if (isUnconditionalBranch()) {
+ Str << Label->getLabelName();
+ } else {
+ getSrc(0)->dump(Func);
+ Str << ", ";
+ getSrc(1)->dump(Func);
+ Str << ", " << Label->getLabelName();
+ }
} else {
if (isUnconditionalBranch()) {
Str << getTargetFalse()->getAsmName();
@@ -886,6 +900,14 @@ template <> void InstMIPS32Ldc1::emitIAS(const Cfg *Func) const {
Asm->ldc1(getDest(), Mem->getBase(), Mem->getOffset(), Reloc);
}
+template <> void InstMIPS32Ll::emitIAS(const Cfg *Func) const {
+ auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
+ auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0));
+ ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset());
+ uint32_t Imm = static_cast<uint32_t>(Offset->getValue());
+ Asm->ll(getDest(), Mem->getBase(), Imm);
+}
+
template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const {
auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0));
@@ -1067,6 +1089,14 @@ template <> void InstMIPS32Ori::emitIAS(const Cfg *Func) const {
Asm->ori(getDest(), getSrc(0), Imm);
}
+template <> void InstMIPS32Sc::emitIAS(const Cfg *Func) const {
+ auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
+ auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(1));
+ ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset());
+ uint32_t Imm = static_cast<uint32_t>(Offset->getValue());
+ Asm->sc(getSrc(0), Mem->getBase(), Imm);
+}
+
template <> void InstMIPS32Sll::emitIAS(const Cfg *Func) const {
auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
Asm->sll(getDest(), getSrc(0), Imm);
@@ -1162,6 +1192,11 @@ template <> void InstMIPS32Swc1::emitIAS(const Cfg *Func) const {
Asm->swc1(getSrc(0), Mem->getBase(), Mem->getOffset(), Reloc);
}
+void InstMIPS32Sync::emitIAS(const Cfg *Func) const {
+ auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
+ Asm->sync();
+}
+
template <> void InstMIPS32Teq::emitIAS(const Cfg *Func) const {
auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
Asm->teq(getSrc(0), getSrc(1), getTrapCode());

Powered by Google App Engine
This is Rietveld 408576698