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

Side by Side Diff: runtime/vm/assembler_mips.h

Issue 593363003: Expands the use of Immediate and Operand wrappers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_ASSEMBLER_MIPS_H_ 5 #ifndef VM_ASSEMBLER_MIPS_H_
6 #define VM_ASSEMBLER_MIPS_H_ 6 #define VM_ASSEMBLER_MIPS_H_
7 7
8 #ifndef VM_ASSEMBLER_H_ 8 #ifndef VM_ASSEMBLER_H_
9 #error Do not include assembler_mips.h directly; use assembler.h instead. 9 #error Do not include assembler_mips.h directly; use assembler.h instead.
10 #endif 10 #endif
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 friend class Assembler; 44 friend class Assembler;
45 }; 45 };
46 46
47 47
48 class Address : public ValueObject { 48 class Address : public ValueObject {
49 public: 49 public:
50 explicit Address(Register base, int32_t offset = 0) 50 explicit Address(Register base, int32_t offset = 0)
51 : ValueObject(), base_(base), offset_(offset) { } 51 : ValueObject(), base_(base), offset_(offset) { }
52 52
53 Address(Register base, Register offset) {
Florian Schneider 2014/09/25 10:34:02 Just declare the constructor without defining it,
zra 2014/09/25 17:34:58 Done.
54 UNREACHABLE();
55 }
56
53 Address(const Address& other) 57 Address(const Address& other)
54 : ValueObject(), base_(other.base_), offset_(other.offset_) { } 58 : ValueObject(), base_(other.base_), offset_(other.offset_) { }
55 Address& operator=(const Address& other) { 59 Address& operator=(const Address& other) {
56 base_ = other.base_; 60 base_ = other.base_;
57 offset_ = other.offset_; 61 offset_ = other.offset_;
58 return *this; 62 return *this;
59 } 63 }
60 64
61 uint32_t encoding() const { 65 uint32_t encoding() const {
62 ASSERT(Utils::IsInt(kImmBits, offset_)); 66 ASSERT(Utils::IsInt(kImmBits, offset_));
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 } else { 929 } else {
926 LoadImmediate(TMP, imm); 930 LoadImmediate(TMP, imm);
927 and_(rd, rs, TMP); 931 and_(rd, rs, TMP);
928 } 932 }
929 } 933 }
930 934
931 void BranchEqual(Register rd, Register rn, Label* l) { 935 void BranchEqual(Register rd, Register rn, Label* l) {
932 beq(rd, rn, l); 936 beq(rd, rn, l);
933 } 937 }
934 938
935 void BranchEqual(Register rd, int32_t value, Label* l) { 939 void BranchEqual(Register rd, const Immediate& imm, Label* l) {
936 ASSERT(!in_delay_slot_); 940 ASSERT(!in_delay_slot_);
937 if (value == 0) { 941 if (imm.value() == 0) {
938 beq(rd, ZR, l); 942 beq(rd, ZR, l);
939 } else { 943 } else {
940 ASSERT(rd != CMPRES2); 944 ASSERT(rd != CMPRES2);
941 LoadImmediate(CMPRES2, value); 945 LoadImmediate(CMPRES2, imm.value());
942 beq(rd, CMPRES2, l); 946 beq(rd, CMPRES2, l);
943 } 947 }
944 } 948 }
945 949
946 void BranchEqual(Register rd, const Object& object, Label* l) { 950 void BranchEqual(Register rd, const Object& object, Label* l) {
947 ASSERT(!in_delay_slot_); 951 ASSERT(!in_delay_slot_);
948 ASSERT(rd != CMPRES2); 952 ASSERT(rd != CMPRES2);
949 LoadObject(CMPRES2, object); 953 LoadObject(CMPRES2, object);
950 beq(rd, CMPRES2, l); 954 beq(rd, CMPRES2, l);
951 } 955 }
952 956
953 void BranchNotEqual(Register rd, Register rn, Label* l) { 957 void BranchNotEqual(Register rd, Register rn, Label* l) {
954 bne(rd, rn, l); 958 bne(rd, rn, l);
955 } 959 }
956 960
957 void BranchNotEqual(Register rd, int32_t value, Label* l) { 961 void BranchNotEqual(Register rd, const Immediate& imm, Label* l) {
958 ASSERT(!in_delay_slot_); 962 ASSERT(!in_delay_slot_);
959 if (value == 0) { 963 if (imm.value() == 0) {
960 bne(rd, ZR, l); 964 bne(rd, ZR, l);
961 } else { 965 } else {
962 ASSERT(rd != CMPRES2); 966 ASSERT(rd != CMPRES2);
963 LoadImmediate(CMPRES2, value); 967 LoadImmediate(CMPRES2, imm.value());
964 bne(rd, CMPRES2, l); 968 bne(rd, CMPRES2, l);
965 } 969 }
966 } 970 }
967 971
968 void BranchNotEqual(Register rd, const Object& object, Label* l) { 972 void BranchNotEqual(Register rd, const Object& object, Label* l) {
969 ASSERT(!in_delay_slot_); 973 ASSERT(!in_delay_slot_);
970 ASSERT(rd != CMPRES2); 974 ASSERT(rd != CMPRES2);
971 LoadObject(CMPRES2, object); 975 LoadObject(CMPRES2, object);
972 bne(rd, CMPRES2, l); 976 bne(rd, CMPRES2, l);
973 } 977 }
974 978
975 void BranchSignedGreater(Register rd, Register rs, Label* l) { 979 void BranchSignedGreater(Register rd, Register rs, Label* l) {
976 ASSERT(!in_delay_slot_); 980 ASSERT(!in_delay_slot_);
977 slt(CMPRES2, rs, rd); // CMPRES2 = rd > rs ? 1 : 0. 981 slt(CMPRES2, rs, rd); // CMPRES2 = rd > rs ? 1 : 0.
978 bne(CMPRES2, ZR, l); 982 bne(CMPRES2, ZR, l);
979 } 983 }
980 984
981 void BranchSignedGreater(Register rd, int32_t value, Label* l) { 985 void BranchSignedGreater(Register rd, const Immediate& imm, Label* l) {
982 ASSERT(!in_delay_slot_); 986 ASSERT(!in_delay_slot_);
983 if (value == 0) { 987 if (imm.value() == 0) {
984 bgtz(rd, l); 988 bgtz(rd, l);
985 } else { 989 } else {
986 ASSERT(rd != CMPRES2); 990 ASSERT(rd != CMPRES2);
987 LoadImmediate(CMPRES2, value); 991 LoadImmediate(CMPRES2, imm.value());
988 BranchSignedGreater(rd, CMPRES2, l); 992 BranchSignedGreater(rd, CMPRES2, l);
989 } 993 }
990 } 994 }
991 995
992 void BranchUnsignedGreater(Register rd, Register rs, Label* l) { 996 void BranchUnsignedGreater(Register rd, Register rs, Label* l) {
993 ASSERT(!in_delay_slot_); 997 ASSERT(!in_delay_slot_);
994 sltu(CMPRES2, rs, rd); 998 sltu(CMPRES2, rs, rd);
995 bne(CMPRES2, ZR, l); 999 bne(CMPRES2, ZR, l);
996 } 1000 }
997 1001
998 void BranchUnsignedGreater(Register rd, int32_t value, Label* l) { 1002 void BranchUnsignedGreater(Register rd, const Immediate& imm, Label* l) {
999 ASSERT(!in_delay_slot_); 1003 ASSERT(!in_delay_slot_);
1000 if (value == 0) { 1004 if (imm.value() == 0) {
1001 BranchNotEqual(rd, 0, l); 1005 BranchNotEqual(rd, Immediate(0), l);
1002 } else { 1006 } else {
1003 ASSERT(rd != CMPRES2); 1007 ASSERT(rd != CMPRES2);
1004 LoadImmediate(CMPRES2, value); 1008 LoadImmediate(CMPRES2, imm.value());
1005 BranchUnsignedGreater(rd, CMPRES2, l); 1009 BranchUnsignedGreater(rd, CMPRES2, l);
1006 } 1010 }
1007 } 1011 }
1008 1012
1009 void BranchSignedGreaterEqual(Register rd, Register rs, Label* l) { 1013 void BranchSignedGreaterEqual(Register rd, Register rs, Label* l) {
1010 ASSERT(!in_delay_slot_); 1014 ASSERT(!in_delay_slot_);
1011 slt(CMPRES2, rd, rs); // CMPRES2 = rd < rs ? 1 : 0. 1015 slt(CMPRES2, rd, rs); // CMPRES2 = rd < rs ? 1 : 0.
1012 beq(CMPRES2, ZR, l); // If CMPRES2 = 0, then rd >= rs. 1016 beq(CMPRES2, ZR, l); // If CMPRES2 = 0, then rd >= rs.
1013 } 1017 }
1014 1018
1015 void BranchSignedGreaterEqual(Register rd, int32_t value, Label* l) { 1019 void BranchSignedGreaterEqual(Register rd, const Immediate& imm, Label* l) {
1016 ASSERT(!in_delay_slot_); 1020 ASSERT(!in_delay_slot_);
1017 if (value == 0) { 1021 if (imm.value() == 0) {
1018 bgez(rd, l); 1022 bgez(rd, l);
1019 } else { 1023 } else {
1020 if (Utils::IsInt(kImmBits, value)) { 1024 if (Utils::IsInt(kImmBits, imm.value())) {
1021 slti(CMPRES2, rd, Immediate(value)); 1025 slti(CMPRES2, rd, imm);
1022 beq(CMPRES2, ZR, l); 1026 beq(CMPRES2, ZR, l);
1023 } else { 1027 } else {
1024 ASSERT(rd != CMPRES2); 1028 ASSERT(rd != CMPRES2);
1025 LoadImmediate(CMPRES2, value); 1029 LoadImmediate(CMPRES2, imm.value());
1026 BranchSignedGreaterEqual(rd, CMPRES2, l); 1030 BranchSignedGreaterEqual(rd, CMPRES2, l);
1027 } 1031 }
1028 } 1032 }
1029 } 1033 }
1030 1034
1031 void BranchUnsignedGreaterEqual(Register rd, Register rs, Label* l) { 1035 void BranchUnsignedGreaterEqual(Register rd, Register rs, Label* l) {
1032 ASSERT(!in_delay_slot_); 1036 ASSERT(!in_delay_slot_);
1033 sltu(CMPRES2, rd, rs); // CMPRES2 = rd < rs ? 1 : 0. 1037 sltu(CMPRES2, rd, rs); // CMPRES2 = rd < rs ? 1 : 0.
1034 beq(CMPRES2, ZR, l); 1038 beq(CMPRES2, ZR, l);
1035 } 1039 }
1036 1040
1037 void BranchUnsignedGreaterEqual(Register rd, int32_t value, Label* l) { 1041 void BranchUnsignedGreaterEqual(Register rd, const Immediate& imm, Label* l) {
1038 ASSERT(!in_delay_slot_); 1042 ASSERT(!in_delay_slot_);
1039 if (value == 0) { 1043 if (imm.value() == 0) {
1040 b(l); 1044 b(l);
1041 } else { 1045 } else {
1042 if (Utils::IsUint(kImmBits, value)) { 1046 if (Utils::IsUint(kImmBits, imm.value())) {
1043 sltiu(CMPRES2, rd, Immediate(value)); 1047 sltiu(CMPRES2, rd, imm);
1044 beq(CMPRES2, ZR, l); 1048 beq(CMPRES2, ZR, l);
1045 } else { 1049 } else {
1046 ASSERT(rd != CMPRES2); 1050 ASSERT(rd != CMPRES2);
1047 LoadImmediate(CMPRES2, value); 1051 LoadImmediate(CMPRES2, imm.value());
1048 BranchUnsignedGreaterEqual(rd, CMPRES2, l); 1052 BranchUnsignedGreaterEqual(rd, CMPRES2, l);
1049 } 1053 }
1050 } 1054 }
1051 } 1055 }
1052 1056
1053 void BranchSignedLess(Register rd, Register rs, Label* l) { 1057 void BranchSignedLess(Register rd, Register rs, Label* l) {
1054 ASSERT(!in_delay_slot_); 1058 ASSERT(!in_delay_slot_);
1055 BranchSignedGreater(rs, rd, l); 1059 BranchSignedGreater(rs, rd, l);
1056 } 1060 }
1057 1061
1058 void BranchSignedLess(Register rd, int32_t value, Label* l) { 1062 void BranchSignedLess(Register rd, const Immediate& imm, Label* l) {
1059 ASSERT(!in_delay_slot_); 1063 ASSERT(!in_delay_slot_);
1060 if (value == 0) { 1064 if (imm.value() == 0) {
1061 bltz(rd, l); 1065 bltz(rd, l);
1062 } else { 1066 } else {
1063 if (Utils::IsInt(kImmBits, value)) { 1067 if (Utils::IsInt(kImmBits, imm.value())) {
1064 slti(CMPRES2, rd, Immediate(value)); 1068 slti(CMPRES2, rd, imm);
1065 bne(CMPRES2, ZR, l); 1069 bne(CMPRES2, ZR, l);
1066 } else { 1070 } else {
1067 ASSERT(rd != CMPRES2); 1071 ASSERT(rd != CMPRES2);
1068 LoadImmediate(CMPRES2, value); 1072 LoadImmediate(CMPRES2, imm.value());
1069 BranchSignedGreater(CMPRES2, rd, l); 1073 BranchSignedGreater(CMPRES2, rd, l);
1070 } 1074 }
1071 } 1075 }
1072 } 1076 }
1073 1077
1074 void BranchUnsignedLess(Register rd, Register rs, Label* l) { 1078 void BranchUnsignedLess(Register rd, Register rs, Label* l) {
1075 ASSERT(!in_delay_slot_); 1079 ASSERT(!in_delay_slot_);
1076 BranchUnsignedGreater(rs, rd, l); 1080 BranchUnsignedGreater(rs, rd, l);
1077 } 1081 }
1078 1082
1079 void BranchUnsignedLess(Register rd, int32_t value, Label* l) { 1083 void BranchUnsignedLess(Register rd, const Immediate& imm, Label* l) {
1080 ASSERT(!in_delay_slot_); 1084 ASSERT(!in_delay_slot_);
1081 ASSERT(value != 0); 1085 ASSERT(imm.value() != 0);
1082 if (Utils::IsUint(kImmBits, value)) { 1086 if (Utils::IsUint(kImmBits, imm.value())) {
1083 sltiu(CMPRES2, rd, Immediate(value)); 1087 sltiu(CMPRES2, rd, imm);
1084 bne(CMPRES2, ZR, l); 1088 bne(CMPRES2, ZR, l);
1085 } else { 1089 } else {
1086 ASSERT(rd != CMPRES2); 1090 ASSERT(rd != CMPRES2);
1087 LoadImmediate(CMPRES2, value); 1091 LoadImmediate(CMPRES2, imm.value());
1088 BranchUnsignedGreater(CMPRES2, rd, l); 1092 BranchUnsignedGreater(CMPRES2, rd, l);
1089 } 1093 }
1090 } 1094 }
1091 1095
1092 void BranchSignedLessEqual(Register rd, Register rs, Label* l) { 1096 void BranchSignedLessEqual(Register rd, Register rs, Label* l) {
1093 ASSERT(!in_delay_slot_); 1097 ASSERT(!in_delay_slot_);
1094 BranchSignedGreaterEqual(rs, rd, l); 1098 BranchSignedGreaterEqual(rs, rd, l);
1095 } 1099 }
1096 1100
1097 void BranchSignedLessEqual(Register rd, int32_t value, Label* l) { 1101 void BranchSignedLessEqual(Register rd, const Immediate& imm, Label* l) {
1098 ASSERT(!in_delay_slot_); 1102 ASSERT(!in_delay_slot_);
1099 if (value == 0) { 1103 if (imm.value() == 0) {
1100 blez(rd, l); 1104 blez(rd, l);
1101 } else { 1105 } else {
1102 ASSERT(rd != CMPRES2); 1106 ASSERT(rd != CMPRES2);
1103 LoadImmediate(CMPRES2, value); 1107 LoadImmediate(CMPRES2, imm.value());
1104 BranchSignedGreaterEqual(CMPRES2, rd, l); 1108 BranchSignedGreaterEqual(CMPRES2, rd, l);
1105 } 1109 }
1106 } 1110 }
1107 1111
1108 void BranchUnsignedLessEqual(Register rd, Register rs, Label* l) { 1112 void BranchUnsignedLessEqual(Register rd, Register rs, Label* l) {
1109 ASSERT(!in_delay_slot_); 1113 ASSERT(!in_delay_slot_);
1110 BranchUnsignedGreaterEqual(rs, rd, l); 1114 BranchUnsignedGreaterEqual(rs, rd, l);
1111 } 1115 }
1112 1116
1113 void BranchUnsignedLessEqual(Register rd, int32_t value, Label* l) { 1117 void BranchUnsignedLessEqual(Register rd, const Immediate& imm, Label* l) {
1114 ASSERT(!in_delay_slot_); 1118 ASSERT(!in_delay_slot_);
1115 ASSERT(rd != CMPRES2); 1119 ASSERT(rd != CMPRES2);
1116 LoadImmediate(CMPRES2, value); 1120 LoadImmediate(CMPRES2, imm.value());
1117 BranchUnsignedGreaterEqual(CMPRES2, rd, l); 1121 BranchUnsignedGreaterEqual(CMPRES2, rd, l);
1118 } 1122 }
1119 1123
1120 void Push(Register rt) { 1124 void Push(Register rt) {
1121 ASSERT(!in_delay_slot_); 1125 ASSERT(!in_delay_slot_);
1122 addiu(SP, SP, Immediate(-kWordSize)); 1126 addiu(SP, SP, Immediate(-kWordSize));
1123 sw(rt, Address(SP)); 1127 sw(rt, Address(SP));
1124 } 1128 }
1125 1129
1126 void Pop(Register rt) { 1130 void Pop(Register rt) {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 Register value, 1408 Register value,
1405 Label* no_update); 1409 Label* no_update);
1406 1410
1407 DISALLOW_ALLOCATION(); 1411 DISALLOW_ALLOCATION();
1408 DISALLOW_COPY_AND_ASSIGN(Assembler); 1412 DISALLOW_COPY_AND_ASSIGN(Assembler);
1409 }; 1413 };
1410 1414
1411 } // namespace dart 1415 } // namespace dart
1412 1416
1413 #endif // VM_ASSEMBLER_MIPS_H_ 1417 #endif // VM_ASSEMBLER_MIPS_H_
OLDNEW
« no previous file with comments | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698