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

Side by Side Diff: src/IceInstARM32.cpp

Issue 1679023008: Add insert/extract element to the integrated ARM assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. 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 unified diff | Download patch
OLDNEW
1 //===- subzero/src/IceInstARM32.cpp - ARM32 instruction implementation ----===// 1 //===- subzero/src/IceInstARM32.cpp - ARM32 instruction implementation ----===//
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 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 } 1058 }
1059 1059
1060 if (Src64 == nullptr) { 1060 if (Src64 == nullptr) {
1061 addSource(Src); 1061 addSource(Src);
1062 } else { 1062 } else {
1063 addSource(Src64->getLo()); 1063 addSource(Src64->getLo());
1064 addSource(Src64->getHi()); 1064 addSource(Src64->getHi());
1065 } 1065 }
1066 } 1066 }
1067 1067
1068 namespace {
1069
1068 // These next two functions find the D register that maps to the half of the Q 1070 // These next two functions find the D register that maps to the half of the Q
1069 // register that this instruction is accessing. 1071 // register that this instruction is accessing.
1070 Register getDRegister(const Variable *Src, uint32_t Index) { 1072 Register getDRegister(const Variable *Src, uint32_t Index) {
1071 assert(Src->hasReg()); 1073 assert(Src->hasReg());
1072 const auto SrcReg = static_cast<Register>(Src->getRegNum()); 1074 const auto SrcReg = static_cast<Register>(Src->getRegNum());
1073 1075
1074 const RegARM32::RegTableType &SrcEntry = RegARM32::RegTable[SrcReg]; 1076 const RegARM32::RegTableType &SrcEntry = RegARM32::RegTable[SrcReg];
1075 assert(SrcEntry.IsVec128); 1077 assert(SrcEntry.IsVec128);
1076 1078
1077 const uint32_t NumElements = typeNumElements(Src->getType()); 1079 const uint32_t NumElements = typeNumElements(Src->getType());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 assert(SrcReg < RegARM32::Reg_q8); 1117 assert(SrcReg < RegARM32::Reg_q8);
1116 1118
1117 // This part assumes the register alias list goes q0, d0, d1, s0, s1, s2, s3. 1119 // This part assumes the register alias list goes q0, d0, d1, s0, s1, s2, s3.
1118 assert(Index < 4); 1120 assert(Index < 4);
1119 1121
1120 // TODO(jpp): find a way to do this that doesn't rely on ordering of the alias 1122 // TODO(jpp): find a way to do this that doesn't rely on ordering of the alias
1121 // list. 1123 // list.
1122 return static_cast<Register>(RegARM32::RegTable[SrcReg].Aliases[Index + 3]); 1124 return static_cast<Register>(RegARM32::RegTable[SrcReg].Aliases[Index + 3]);
1123 } 1125 }
1124 1126
1127 } // end of anonymous namespace
1128
1125 void InstARM32Extract::emit(const Cfg *Func) const { 1129 void InstARM32Extract::emit(const Cfg *Func) const {
1126 Ostream &Str = Func->getContext()->getStrEmit(); 1130 Ostream &Str = Func->getContext()->getStrEmit();
1127 const Type DestTy = getDest()->getType(); 1131 const Type DestTy = getDest()->getType();
1128 1132
1129 const auto *Src = llvm::cast<Variable>(getSrc(0)); 1133 const auto *Src = llvm::cast<Variable>(getSrc(0));
1130 1134
1131 if (isIntegerType(DestTy)) { 1135 if (isIntegerType(DestTy)) {
1132 Str << "\t" 1136 Str << "\t"
1133 << "vmov" << getPredicate(); 1137 << "vmov" << getPredicate();
1134 const uint32_t BitSize = typeWidthInBytes(DestTy) * CHAR_BIT; 1138 const uint32_t BitSize = typeWidthInBytes(DestTy) * CHAR_BIT;
(...skipping 18 matching lines...) Expand all
1153 Str << "\t" 1157 Str << "\t"
1154 << "vmov" << getPredicate() << ".f32" 1158 << "vmov" << getPredicate() << ".f32"
1155 << "\t"; 1159 << "\t";
1156 getDest()->emit(Func); 1160 getDest()->emit(Func);
1157 Str << ", " << RegARM32::RegTable[SrcReg].Name; 1161 Str << ", " << RegARM32::RegTable[SrcReg].Name;
1158 } else { 1162 } else {
1159 assert(false && "Invalid extract type"); 1163 assert(false && "Invalid extract type");
1160 } 1164 }
1161 } 1165 }
1162 1166
1167 void InstARM32Extract::emitIAS(const Cfg *Func) const {
1168 const Operand *Dest = getDest();
1169 const Type DestTy = Dest->getType();
1170 const Operand *Src = getSrc(0);
1171 const Type SrcTy = Src->getType();
1172 assert(isVectorType(SrcTy));
1173 assert(DestTy == typeElementType(SrcTy));
1174 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
1175 if (isIntegerType(DestTy)) {
1176 Asm->vmovrqi(Dest, Src, Index, getPredicate());
1177 assert(!Asm->needsTextFixup());
1178 return;
1179 }
1180 assert(isFloatingType(DestTy));
1181 Asm->vmovsqi(Dest, Src, Index, getPredicate());
1182 assert(!Asm->needsTextFixup());
1183 }
1184
1163 void InstARM32Insert::emit(const Cfg *Func) const { 1185 void InstARM32Insert::emit(const Cfg *Func) const {
1164 Ostream &Str = Func->getContext()->getStrEmit(); 1186 Ostream &Str = Func->getContext()->getStrEmit();
1165 const Variable *Dest = getDest(); 1187 const Variable *Dest = getDest();
1166 const Type DestTy = getDest()->getType(); 1188 const Type DestTy = getDest()->getType();
1167 1189
1168 const auto *Src = llvm::cast<Variable>(getSrc(0)); 1190 const auto *Src = llvm::cast<Variable>(getSrc(0));
1169 1191
1170 if (isIntegerType(DestTy)) { 1192 if (isIntegerType(DestTy)) {
1171 Str << "\t" 1193 Str << "\t"
1172 << "vmov" << getPredicate(); 1194 << "vmov" << getPredicate();
(...skipping 11 matching lines...) Expand all
1184 << "vmov" << getPredicate() << ".f32" 1206 << "vmov" << getPredicate() << ".f32"
1185 << "\t"; 1207 << "\t";
1186 const Register DestReg = getSRegister(Dest, Index); 1208 const Register DestReg = getSRegister(Dest, Index);
1187 Str << RegARM32::RegTable[DestReg].Name << ", "; 1209 Str << RegARM32::RegTable[DestReg].Name << ", ";
1188 Src->emit(Func); 1210 Src->emit(Func);
1189 } else { 1211 } else {
1190 assert(false && "Invalid insert type"); 1212 assert(false && "Invalid insert type");
1191 } 1213 }
1192 } 1214 }
1193 1215
1216 void InstARM32Insert::emitIAS(const Cfg *Func) const {
1217 const Variable *Dest = getDest();
1218 const Type DestTy = getDest()->getType();
1219 const Operand *Src = getSrc(0);
1220 const Type SrcTy = Src->getType();
1221 assert(isVectorType(DestTy));
1222 assert(typeElementType(DestTy) == SrcTy);
1223 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
1224 if (isIntegerType(SrcTy)) {
1225 const Operand *Src = getSrc(0);
1226 Asm->vmovqir(Dest, Index, Src, getPredicate());
1227 assert(!Asm->needsTextFixup());
1228 return;
1229 }
1230 assert(isFloatingType(SrcTy));
1231 Asm->vmovqis(Dest, Index, Src, getPredicate());
1232 assert(!Asm->needsTextFixup());
1233 }
1234
1194 template <InstARM32::InstKindARM32 K> 1235 template <InstARM32::InstKindARM32 K>
1195 void InstARM32CmpLike<K>::emitIAS(const Cfg *Func) const { 1236 void InstARM32CmpLike<K>::emitIAS(const Cfg *Func) const {
1196 emitUsingTextFixup(Func); 1237 emitUsingTextFixup(Func);
1197 } 1238 }
1198 1239
1199 template <> void InstARM32Cmn::emitIAS(const Cfg *Func) const { 1240 template <> void InstARM32Cmn::emitIAS(const Cfg *Func) const {
1200 assert(getSrcSize() == 2); 1241 assert(getSrcSize() == 2);
1201 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); 1242 auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
1202 Asm->cmn(getSrc(0), getSrc(1), getPredicate()); 1243 Asm->cmn(getSrc(0), getSrc(1), getPredicate());
1203 if (Asm->needsTextFixup()) 1244 if (Asm->needsTextFixup())
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 2753
2713 template class InstARM32FourAddrGPR<InstARM32::Mla>; 2754 template class InstARM32FourAddrGPR<InstARM32::Mla>;
2714 template class InstARM32FourAddrGPR<InstARM32::Mls>; 2755 template class InstARM32FourAddrGPR<InstARM32::Mls>;
2715 2756
2716 template class InstARM32CmpLike<InstARM32::Cmn>; 2757 template class InstARM32CmpLike<InstARM32::Cmn>;
2717 template class InstARM32CmpLike<InstARM32::Cmp>; 2758 template class InstARM32CmpLike<InstARM32::Cmp>;
2718 template class InstARM32CmpLike<InstARM32::Tst>; 2759 template class InstARM32CmpLike<InstARM32::Tst>;
2719 2760
2720 } // end of namespace ARM32 2761 } // end of namespace ARM32
2721 } // end of namespace Ice 2762 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698