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

Side by Side Diff: src/IceTargetLoweringMIPS32.cpp

Issue 2368343003: Subzero, MIPS32: Intrinsic call Bswap for i16, i32 and i64 (Closed)
Patch Set: 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
OLDNEW
1 // 1 //
2 // The Subzero Code Generator 2 // The Subzero Code Generator
3 // 3 //
4 // This file is distributed under the University of Illinois Open Source 4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details. 5 // License. See LICENSE.TXT for details.
6 // 6 //
7 //===----------------------------------------------------------------------===// 7 //===----------------------------------------------------------------------===//
8 /// 8 ///
9 /// \file 9 /// \file
10 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost 10 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost
(...skipping 2998 matching lines...) Expand 10 before | Expand all | Expand 10 after
3009 return; 3009 return;
3010 } 3010 }
3011 case Intrinsics::AtomicRMW: 3011 case Intrinsics::AtomicRMW:
3012 UnimplementedLoweringError(this, Instr); 3012 UnimplementedLoweringError(this, Instr);
3013 return; 3013 return;
3014 case Intrinsics::AtomicStore: { 3014 case Intrinsics::AtomicStore: {
3015 UnimplementedLoweringError(this, Instr); 3015 UnimplementedLoweringError(this, Instr);
3016 return; 3016 return;
3017 } 3017 }
3018 case Intrinsics::Bswap: { 3018 case Intrinsics::Bswap: {
3019 UnimplementedLoweringError(this, Instr); 3019 auto *Src = Instr->getArg(0);
3020 const Type SrcTy = Src->getType();
3021 assert(SrcTy == IceType_i16 || SrcTy == IceType_i32 ||
3022 SrcTy == IceType_i64);
3023 switch (SrcTy) {
3024 case IceType_i16: {
3025 auto *T1 = I32Reg();
3026 auto *T2 = I32Reg();
3027 auto *T3 = I32Reg();
3028 auto *T4 = I32Reg();
3029 auto *SrcR = legalizeToReg(Src);
3030 _sll(T1, SrcR, 8);
3031 _lui(T2, Ctx->getConstantInt32(255));
3032 _and(T1, T1, T2);
3033 _sll(T3, SrcR, 24);
3034 _or(T1, T3, T1);
3035 _srl(T4, T1, 16);
3036 _mov(Dest, T4);
3037 break;
Jim Stichnoth 2016/09/27 04:20:32 Can this "break" be changed to "return"? That wou
obucinac 2016/09/27 14:22:01 Done.
3038 }
3039 case IceType_i32: {
3040 auto *T1 = I32Reg();
3041 auto *T2 = I32Reg();
3042 auto *T3 = I32Reg();
3043 auto *T4 = I32Reg();
3044 auto *T5 = I32Reg();
3045 auto *SrcR = legalizeToReg(Src);
3046 _srl(T1, SrcR, 24);
3047 _srl(T2, SrcR, 8);
3048 _andi(T2, T2, 65280);
Jim Stichnoth 2016/09/27 04:20:32 Maybe this strange-looking constant would be more
obucinac 2016/09/27 14:22:01 Done.
3049 _or(T1, T2, T1);
3050 _sll(T4, SrcR, 8);
3051 _lui(T3, Ctx->getConstantInt32(255));
3052 _and(T4, T4, T3);
3053 _sll(T5, SrcR, 24);
3054 _or(T4, T5, T4);
3055 _or(T4, T4, T1);
3056 _mov(Dest, T4);
3057 break;
3058 }
3059 case IceType_i64: {
3060 auto *T1 = I32Reg();
3061 auto *T2 = I32Reg();
3062 auto *T3 = I32Reg();
3063 auto *T4 = I32Reg();
3064 auto *T5 = I32Reg();
3065 auto *T6 = I32Reg();
3066 auto *T7 = I32Reg();
3067 auto *T8 = I32Reg();
3068 auto *T9 = I32Reg();
3069 auto *T10 = I32Reg();
3070 auto *T11 = I32Reg();
3071 auto *T12 = I32Reg();
3072 auto *T13 = I32Reg();
3073 auto *T14 = I32Reg();
3074 auto *T15 = I32Reg();
3075 auto *T16 = I32Reg();
3076 auto *T17 = I32Reg();
3077 auto *T18 = I32Reg();
3078 auto *DestLo = llvm::cast<Variable>(loOperand(Dest));
3079 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest));
3080 Src = legalizeUndef(Src);
3081 auto *SrcLoR = legalizeToReg(loOperand(Src));
3082 auto *SrcHiR = legalizeToReg(hiOperand(Src));
3083 _sll(T1, SrcHiR, 8);
3084 _srl(T2, SrcHiR, 24);
3085 _srl(T3, SrcHiR, 8);
3086 _andi(T3, T3, 65280);
3087 _lui(T4, Ctx->getConstantInt32(255));
3088 _or(T5, T3, T2);
3089 _and(T6, T1, T4);
3090 _sll(T7, SrcHiR, 24);
3091 _or(T8, T7, T6);
3092 _srl(T9, SrcLoR, 24);
3093 _srl(T10, SrcLoR, 8);
3094 _andi(T11, T10, 65280);
3095 _or(T12, T8, T5);
3096 _or(T13, T11, T9);
3097 _sll(T14, SrcLoR, 8);
3098 _and(T15, T14, T4);
3099 _sll(T16, SrcLoR, 24);
3100 _or(T17, T16, T15);
3101 _or(T18, T17, T13);
3102 _mov(DestLo, T12);
3103 _mov(DestHi, T18);
3104 break;
3105 }
3106 default:
3107 llvm::report_fatal_error("Control flow should never have reached here.");
3108 }
3020 return; 3109 return;
3021 } 3110 }
3022 case Intrinsics::Ctpop: { 3111 case Intrinsics::Ctpop: {
3023 llvm::report_fatal_error("Ctpop should have been prelowered."); 3112 llvm::report_fatal_error("Ctpop should have been prelowered.");
3024 return; 3113 return;
3025 } 3114 }
3026 case Intrinsics::Ctlz: { 3115 case Intrinsics::Ctlz: {
3027 auto *Src = Instr->getArg(0); 3116 auto *Src = Instr->getArg(0);
3028 const Type SrcTy = Src->getType(); 3117 const Type SrcTy = Src->getType();
3029 assert(SrcTy == IceType_i32 || SrcTy == IceType_i64); 3118 assert(SrcTy == IceType_i32 || SrcTy == IceType_i64);
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 Str << "\t.set\t" 4069 Str << "\t.set\t"
3981 << "nomips16\n"; 4070 << "nomips16\n";
3982 } 4071 }
3983 4072
3984 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM]; 4073 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM];
3985 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM]; 4074 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM];
3986 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; 4075 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM];
3987 4076
3988 } // end of namespace MIPS32 4077 } // end of namespace MIPS32
3989 } // end of namespace Ice 4078 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698