OLD | NEW |
---|---|
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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 InstARM32Umull::InstARM32Umull(Cfg *Func, Variable *DestLo, Variable *DestHi, | 370 InstARM32Umull::InstARM32Umull(Cfg *Func, Variable *DestLo, Variable *DestHi, |
371 Variable *Src0, Variable *Src1, | 371 Variable *Src0, Variable *Src1, |
372 CondARM32::Cond Predicate) | 372 CondARM32::Cond Predicate) |
373 : InstARM32Pred(Func, InstARM32::Umull, 2, DestLo, Predicate), | 373 : InstARM32Pred(Func, InstARM32::Umull, 2, DestLo, Predicate), |
374 // DestHi is expected to have a FakeDef inserted by the lowering code. | 374 // DestHi is expected to have a FakeDef inserted by the lowering code. |
375 DestHi(DestHi) { | 375 DestHi(DestHi) { |
376 addSource(Src0); | 376 addSource(Src0); |
377 addSource(Src1); | 377 addSource(Src1); |
378 } | 378 } |
379 | 379 |
380 InstARM32Vcvt::InstARM32Vcvt(Cfg *Func, Variable *Dest, Variable *Src, | |
381 VcvtVariant Variant, CondARM32::Cond Predicate) | |
382 : InstARM32Pred(Func, InstARM32::Vcvt, 1, Dest, Predicate), | |
383 Variant(Variant) { | |
384 addSource(Src); | |
385 } | |
386 | |
380 // ======================== Dump routines ======================== // | 387 // ======================== Dump routines ======================== // |
381 | 388 |
382 // Two-addr ops | 389 // Two-addr ops |
383 template <> const char *InstARM32Movt::Opcode = "movt"; | 390 template <> const char *InstARM32Movt::Opcode = "movt"; |
384 // Unary ops | 391 // Unary ops |
385 template <> const char *InstARM32Movw::Opcode = "movw"; | 392 template <> const char *InstARM32Movw::Opcode = "movw"; |
386 template <> const char *InstARM32Clz::Opcode = "clz"; | 393 template <> const char *InstARM32Clz::Opcode = "clz"; |
387 template <> const char *InstARM32Mvn::Opcode = "mvn"; | 394 template <> const char *InstARM32Mvn::Opcode = "mvn"; |
388 template <> const char *InstARM32Rbit::Opcode = "rbit"; | 395 template <> const char *InstARM32Rbit::Opcode = "rbit"; |
389 template <> const char *InstARM32Rev::Opcode = "rev"; | 396 template <> const char *InstARM32Rev::Opcode = "rev"; |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
902 if (!BuildDefs::dump()) | 909 if (!BuildDefs::dump()) |
903 return; | 910 return; |
904 Ostream &Str = Func->getContext()->getStrDump(); | 911 Ostream &Str = Func->getContext()->getStrDump(); |
905 dumpDest(Func); | 912 dumpDest(Func); |
906 Str << " = "; | 913 Str << " = "; |
907 dumpOpcodePred(Str, "umull", getDest()->getType()); | 914 dumpOpcodePred(Str, "umull", getDest()->getType()); |
908 Str << " "; | 915 Str << " "; |
909 dumpSources(Func); | 916 dumpSources(Func); |
910 } | 917 } |
911 | 918 |
919 namespace { | |
920 const char *vcvtVariantSuffix(const InstARM32Vcvt::VcvtVariant Variant) { | |
921 switch (Variant) { | |
922 case InstARM32Vcvt::S2si: | |
923 return ".s32.f32"; | |
924 case InstARM32Vcvt::S2ui: | |
925 return ".u32.f32"; | |
926 case InstARM32Vcvt::Si2s: | |
927 return ".f32.s32"; | |
928 case InstARM32Vcvt::Ui2s: | |
929 return ".f32.u32"; | |
930 case InstARM32Vcvt::D2si: | |
931 return ".s32.f64"; | |
932 case InstARM32Vcvt::D2ui: | |
933 return ".u32.f64"; | |
934 case InstARM32Vcvt::Si2d: | |
935 return ".f64.s32"; | |
936 case InstARM32Vcvt::Ui2d: | |
937 return ".f64.u32"; | |
938 case InstARM32Vcvt::S2d: | |
939 return ".f64.f32"; | |
940 case InstARM32Vcvt::D2s: | |
941 return ".f32.f64"; | |
942 } | |
943 llvm::report_fatal_error("Invalid VcvtVariant enum."); | |
944 } | |
945 } // end of anonymous namespace | |
ascull
2015/09/10 16:44:09
Why an anonymous namespace function rather than a
John
2015/09/11 12:16:48
The choice of one versus the other is more of a pe
| |
946 | |
947 void InstARM32Vcvt::emit(const Cfg *Func) const { | |
948 if (!BuildDefs::dump()) | |
949 return; | |
950 Ostream &Str = Func->getContext()->getStrEmit(); | |
951 assert(getSrcSize() == 1); | |
952 assert(getDest()->hasReg()); | |
953 Str << "\t" | |
954 << "vcvt" << getPredicate() << vcvtVariantSuffix(Variant) << "\t"; | |
955 getDest()->emit(Func); | |
956 Str << ", "; | |
957 getSrc(0)->emit(Func); | |
958 } | |
959 | |
960 void InstARM32Vcvt::emitIAS(const Cfg *Func) const { | |
961 assert(getSrcSize() == 1); | |
962 (void)Func; | |
963 llvm_unreachable("Not yet implemented"); | |
964 } | |
965 | |
966 void InstARM32Vcvt::dump(const Cfg *Func) const { | |
967 if (!BuildDefs::dump()) | |
968 return; | |
969 Ostream &Str = Func->getContext()->getStrDump(); | |
970 dumpDest(Func); | |
971 Str << " = " | |
972 << "vcvt" << getPredicate() << vcvtVariantSuffix(Variant) << " "; | |
973 dumpSources(Func); | |
974 } | |
975 | |
912 void OperandARM32Mem::emit(const Cfg *Func) const { | 976 void OperandARM32Mem::emit(const Cfg *Func) const { |
913 if (!BuildDefs::dump()) | 977 if (!BuildDefs::dump()) |
914 return; | 978 return; |
915 Ostream &Str = Func->getContext()->getStrEmit(); | 979 Ostream &Str = Func->getContext()->getStrEmit(); |
916 Str << "["; | 980 Str << "["; |
917 getBase()->emit(Func); | 981 getBase()->emit(Func); |
918 switch (getAddrMode()) { | 982 switch (getAddrMode()) { |
919 case PostIndex: | 983 case PostIndex: |
920 case NegPostIndex: | 984 case NegPostIndex: |
921 Str << "], "; | 985 Str << "], "; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1018 if (getShiftOp() != kNoShift) { | 1082 if (getShiftOp() != kNoShift) { |
1019 Str << ", " << InstARM32ShiftAttributes[getShiftOp()].EmitString << " "; | 1083 Str << ", " << InstARM32ShiftAttributes[getShiftOp()].EmitString << " "; |
1020 if (Func) | 1084 if (Func) |
1021 getShiftAmt()->dump(Func); | 1085 getShiftAmt()->dump(Func); |
1022 else | 1086 else |
1023 getShiftAmt()->dump(Str); | 1087 getShiftAmt()->dump(Str); |
1024 } | 1088 } |
1025 } | 1089 } |
1026 | 1090 |
1027 } // end of namespace Ice | 1091 } // end of namespace Ice |
OLD | NEW |