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

Side by Side Diff: src/IceInstMIPS32.h

Issue 2420033002: [SubZero] Handle relocatable constants for MIPS (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addressed review comments Created 4 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
« no previous file with comments | « no previous file | src/IceTargetLoweringMIPS32.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 //===- subzero/src/IceInstMIPS32.h - MIPS32 machine instrs --*- C++ -*-----===// 1 //===- subzero/src/IceInstMIPS32.h - MIPS32 machine instrs --*- C++ -*-----===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 }; 976 };
977 977
978 template <InstMIPS32::InstKindMIPS32 K, bool Signed = false> 978 template <InstMIPS32::InstKindMIPS32 K, bool Signed = false>
979 class InstMIPS32Imm16 : public InstMIPS32 { 979 class InstMIPS32Imm16 : public InstMIPS32 {
980 InstMIPS32Imm16() = delete; 980 InstMIPS32Imm16() = delete;
981 InstMIPS32Imm16(const InstMIPS32Imm16 &) = delete; 981 InstMIPS32Imm16(const InstMIPS32Imm16 &) = delete;
982 InstMIPS32Imm16 &operator=(const InstMIPS32Imm16 &) = delete; 982 InstMIPS32Imm16 &operator=(const InstMIPS32Imm16 &) = delete;
983 983
984 public: 984 public:
985 static InstMIPS32Imm16 *create(Cfg *Func, Variable *Dest, Operand *Source, 985 static InstMIPS32Imm16 *create(Cfg *Func, Variable *Dest, Operand *Source,
986 uint32_t Imm) { 986 uint32_t Imm, RelocOp Reloc = RO_No) {
987 return new (Func->allocate<InstMIPS32Imm16>()) 987 return new (Func->allocate<InstMIPS32Imm16>())
988 InstMIPS32Imm16(Func, Dest, Source, Imm); 988 InstMIPS32Imm16(Func, Dest, Source, Imm, Reloc);
989 } 989 }
990 990
991 static InstMIPS32Imm16 *create(Cfg *Func, Variable *Dest, uint32_t Imm) { 991 static InstMIPS32Imm16 *create(Cfg *Func, Variable *Dest, uint32_t Imm,
992 RelocOp Reloc = RO_No) {
992 return new (Func->allocate<InstMIPS32Imm16>()) 993 return new (Func->allocate<InstMIPS32Imm16>())
993 InstMIPS32Imm16(Func, Dest, Imm); 994 InstMIPS32Imm16(Func, Dest, Imm, Reloc);
995 }
996
997 static InstMIPS32Imm16 *create(Cfg *Func, Variable *Dest, Operand *Src0,
998 Operand *Src1, RelocOp Reloc) {
999 return new (Func->allocate<InstMIPS32Imm16>())
1000 InstMIPS32Imm16(Func, Dest, Src0, Src1, Reloc);
994 } 1001 }
995 1002
996 void emit(const Cfg *Func) const override { 1003 void emit(const Cfg *Func) const override {
997 if (!BuildDefs::dump()) 1004 if (!BuildDefs::dump())
998 return; 1005 return;
999 Ostream &Str = Func->getContext()->getStrEmit(); 1006 Ostream &Str = Func->getContext()->getStrEmit();
1000 Str << "\t" << Opcode << "\t"; 1007 Str << "\t" << Opcode << "\t";
1001 getDest()->emit(Func); 1008 getDest()->emit(Func);
1002 if (getSrcSize() > 0) { 1009 if (getSrcSize() > 0) {
1003 Str << ", "; 1010 Str << ", ";
1004 getSrc(0)->emit(Func); 1011 getSrc(0)->emit(Func);
1005 } 1012 }
1006 Str << ", "; 1013 Str << ", ";
1007 if (Signed) 1014 if (Reloc == RO_No) {
1008 Str << (int32_t)Imm; 1015 if (Signed)
1009 else 1016 Str << (int32_t)Imm;
1010 Str << Imm; 1017 else
1018 Str << Imm;
1019 } else {
1020 auto *CR = llvm::dyn_cast<ConstantRelocatable>(getSrc(1));
1021 emitRelocOp(Str, Reloc);
1022 Str << "(";
1023 CR->emitWithoutPrefix(Func->getTarget());
1024 Str << ")";
1025 }
1011 } 1026 }
1012 1027
1013 void emitIAS(const Cfg *Func) const override { 1028 void emitIAS(const Cfg *Func) const override {
1014 (void)Func; 1029 (void)Func;
1015 llvm_unreachable("Not yet implemented"); 1030 llvm_unreachable("Not yet implemented");
1016 } 1031 }
1017 void dump(const Cfg *Func) const override { 1032 void dump(const Cfg *Func) const override {
1018 if (!BuildDefs::dump()) 1033 if (!BuildDefs::dump())
1019 return; 1034 return;
1020 Ostream &Str = Func->getContext()->getStrDump(); 1035 Ostream &Str = Func->getContext()->getStrDump();
1021 dumpOpcode(Str, Opcode, getDest()->getType()); 1036 dumpOpcode(Str, Opcode, getDest()->getType());
1022 Str << " "; 1037 Str << " ";
1023 dumpDest(Func); 1038 dumpDest(Func);
1024 Str << ", "; 1039 Str << ", ";
1025 dumpSources(Func); 1040 if (Reloc == RO_No) {
1026 Str << ", "; 1041 dumpSources(Func);
1027 if (Signed) 1042 Str << ", ";
1028 Str << (int32_t)Imm; 1043 if (Signed)
1029 else 1044 Str << (int32_t)Imm;
1030 Str << Imm; 1045 else
1046 Str << Imm;
1047 } else {
1048 getSrc(0)->dump(Func);
1049 Str << ",";
1050 emitRelocOp(Str, Reloc);
1051 Str << "(";
1052 getSrc(1)->dump(Func);
1053 Str << ")";
1054 }
1031 } 1055 }
1032 1056
1033 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } 1057 static bool classof(const Inst *Inst) { return isClassof(Inst, K); }
1034 1058
1035 private: 1059 private:
1036 InstMIPS32Imm16(Cfg *Func, Variable *Dest, Operand *Source, uint32_t Imm) 1060 InstMIPS32Imm16(Cfg *Func, Variable *Dest, Operand *Source, uint32_t Imm,
1037 : InstMIPS32(Func, K, 1, Dest), Imm(Imm) { 1061 RelocOp Reloc = RO_No)
1062 : InstMIPS32(Func, K, 1, Dest), Reloc(Reloc), Imm(Imm) {
1038 addSource(Source); 1063 addSource(Source);
1039 } 1064 }
1040 1065
1041 InstMIPS32Imm16(Cfg *Func, Variable *Dest, uint32_t Imm) 1066 InstMIPS32Imm16(Cfg *Func, Variable *Dest, uint32_t Imm,
1042 : InstMIPS32(Func, K, 0, Dest), Imm(Imm) {} 1067 RelocOp Reloc = RO_No)
1068 : InstMIPS32(Func, K, 0, Dest), Reloc(Reloc), Imm(Imm) {}
1069
1070 InstMIPS32Imm16(Cfg *Func, Variable *Dest, Operand *Src0, Operand *Src1,
1071 RelocOp Reloc = RO_No)
1072 : InstMIPS32(Func, K, 1, Dest), Reloc(Reloc), Imm(0) {
1073 addSource(Src0);
1074 addSource(Src1);
1075 }
1043 1076
1044 static const char *Opcode; 1077 static const char *Opcode;
1045 1078 const RelocOp Reloc;
1046 const uint32_t Imm; 1079 const uint32_t Imm;
1047 }; 1080 };
1048 1081
1049 /// Conditional mov 1082 /// Conditional mov
1050 template <InstMIPS32::InstKindMIPS32 K> 1083 template <InstMIPS32::InstKindMIPS32 K>
1051 class InstMIPS32MovConditional : public InstMIPS32 { 1084 class InstMIPS32MovConditional : public InstMIPS32 {
1052 InstMIPS32MovConditional() = delete; 1085 InstMIPS32MovConditional() = delete;
1053 InstMIPS32MovConditional(const InstMIPS32MovConditional &) = delete; 1086 InstMIPS32MovConditional(const InstMIPS32MovConditional &) = delete;
1054 InstMIPS32MovConditional & 1087 InstMIPS32MovConditional &
1055 operator=(const InstMIPS32MovConditional &) = delete; 1088 operator=(const InstMIPS32MovConditional &) = delete;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 template <> void InstMIPS32Trunc_l_s::emitIAS(const Cfg *Func) const; 1351 template <> void InstMIPS32Trunc_l_s::emitIAS(const Cfg *Func) const;
1319 template <> void InstMIPS32Trunc_w_d::emitIAS(const Cfg *Func) const; 1352 template <> void InstMIPS32Trunc_w_d::emitIAS(const Cfg *Func) const;
1320 template <> void InstMIPS32Trunc_w_s::emitIAS(const Cfg *Func) const; 1353 template <> void InstMIPS32Trunc_w_s::emitIAS(const Cfg *Func) const;
1321 template <> void InstMIPS32Xor::emitIAS(const Cfg *Func) const; 1354 template <> void InstMIPS32Xor::emitIAS(const Cfg *Func) const;
1322 template <> void InstMIPS32Xori::emitIAS(const Cfg *Func) const; 1355 template <> void InstMIPS32Xori::emitIAS(const Cfg *Func) const;
1323 1356
1324 } // end of namespace MIPS32 1357 } // end of namespace MIPS32
1325 } // end of namespace Ice 1358 } // end of namespace Ice
1326 1359
1327 #endif // SUBZERO_SRC_ICEINSTMIPS32_H 1360 #endif // SUBZERO_SRC_ICEINSTMIPS32_H
OLDNEW
« no previous file with comments | « no previous file | src/IceTargetLoweringMIPS32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698