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

Unified Diff: src/mips64/macro-assembler-mips64.cc

Issue 1714283002: MIPS64: Fix 'MIPS: use DAHI/DATH for li macro on mips64r6.' (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: code cleanup. Created 4 years, 10 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/mips64/macro-assembler-mips64.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips64/macro-assembler-mips64.cc
diff --git a/src/mips64/macro-assembler-mips64.cc b/src/mips64/macro-assembler-mips64.cc
index fcc602bbffd4a816b61cefd53e276090814b6e7c..4d9c0c4b650a0321f119248c259312c9016718aa 100644
--- a/src/mips64/macro-assembler-mips64.cc
+++ b/src/mips64/macro-assembler-mips64.cc
@@ -1358,6 +1358,27 @@ void MacroAssembler::li(Register dst, Handle<Object> value, LiFlags mode) {
}
}
+static inline int64_t ShiftAndFixSignExtension(int64_t imm, int bitnum) {
+ if ((imm >> (bitnum - 1)) & 0x1) {
+ imm = (imm >> bitnum) + 1;
+ } else {
+ imm = imm >> bitnum;
+ }
+ return imm;
+}
+
+void MacroAssembler::LiLower32BitHelper(Register rd, Operand j) {
+ if (is_int16(j.imm64_)) {
+ daddiu(rd, zero_reg, (j.imm64_ & kImm16Mask));
+ } else if (!(j.imm64_ & kHiMask)) {
+ ori(rd, zero_reg, (j.imm64_ & kImm16Mask));
+ } else if (!(j.imm64_ & kImm16Mask)) {
+ lui(rd, (j.imm64_ >> kLuiShift) & kImm16Mask);
+ } else {
+ lui(rd, (j.imm64_ >> kLuiShift) & kImm16Mask);
+ ori(rd, rd, (j.imm64_ & kImm16Mask));
+ }
+}
void MacroAssembler::li(Register rd, Operand j, LiFlags mode) {
DCHECK(!j.is_reg());
@@ -1365,43 +1386,17 @@ void MacroAssembler::li(Register rd, Operand j, LiFlags mode) {
if (!MustUseReg(j.rmode_) && mode == OPTIMIZE_SIZE) {
// Normal load of an immediate value which does not need Relocation Info.
if (is_int32(j.imm64_)) {
- if (is_int16(j.imm64_)) {
- daddiu(rd, zero_reg, (j.imm64_ & kImm16Mask));
- } else if (!(j.imm64_ & kHiMask)) {
- ori(rd, zero_reg, (j.imm64_ & kImm16Mask));
- } else if (!(j.imm64_ & kImm16Mask)) {
- lui(rd, (j.imm64_ >> kLuiShift) & kImm16Mask);
- } else {
- lui(rd, (j.imm64_ >> kLuiShift) & kImm16Mask);
- ori(rd, rd, (j.imm64_ & kImm16Mask));
- }
+ LiLower32BitHelper(rd, j);
} else {
if (kArchVariant == kMips64r6) {
int64_t imm = j.imm64_;
- bool lui_emited = false;
- if (((imm >> kLuiShift) & kImm16Mask) != 0) {
- lui(rd, (imm >> kLuiShift) & kImm16Mask);
- lui_emited = true;
- }
- if ((imm & kImm16Mask) != 0) {
- ori(rd, rd, (imm & kImm16Mask));
- } else if (!lui_emited) {
- or_(rd, zero_reg, zero_reg);
- }
- if ((imm >> 31) & 0x1) {
- imm = (imm >> 32) + 1;
- } else {
- imm = imm >> 32;
- }
+ LiLower32BitHelper(rd, j);
+ imm = ShiftAndFixSignExtension(imm, 32);
if (imm & kImm16Mask) {
dahi(rd, imm & kImm16Mask);
}
if (!is_int48(j.imm64_)) {
- if ((imm >> 15) & 0x1) {
- imm = (imm >> 16) + 1;
- } else {
- imm = imm >> 16;
- }
+ imm = ShiftAndFixSignExtension(imm, 16);
if (imm & kImm16Mask) {
dati(rd, imm & kImm16Mask);
}
« no previous file with comments | « src/mips64/macro-assembler-mips64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698