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: Addressing 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 | « src/IceInstMIPS32.h ('k') | tests_lit/assembler/mips32/encoding_intrinsics.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3031 matching lines...) Expand 10 before | Expand all | Expand 10 after
3042 return; 3042 return;
3043 } 3043 }
3044 case Intrinsics::AtomicRMW: 3044 case Intrinsics::AtomicRMW:
3045 UnimplementedLoweringError(this, Instr); 3045 UnimplementedLoweringError(this, Instr);
3046 return; 3046 return;
3047 case Intrinsics::AtomicStore: { 3047 case Intrinsics::AtomicStore: {
3048 UnimplementedLoweringError(this, Instr); 3048 UnimplementedLoweringError(this, Instr);
3049 return; 3049 return;
3050 } 3050 }
3051 case Intrinsics::Bswap: { 3051 case Intrinsics::Bswap: {
3052 UnimplementedLoweringError(this, Instr); 3052 auto *Src = Instr->getArg(0);
3053 const Type SrcTy = Src->getType();
3054 assert(SrcTy == IceType_i16 || SrcTy == IceType_i32 ||
3055 SrcTy == IceType_i64);
3056 switch (SrcTy) {
3057 case IceType_i16: {
3058 auto *T1 = I32Reg();
3059 auto *T2 = I32Reg();
3060 auto *T3 = I32Reg();
3061 auto *T4 = I32Reg();
3062 auto *SrcR = legalizeToReg(Src);
3063 _sll(T1, SrcR, 8);
3064 _lui(T2, Ctx->getConstantInt32(255));
3065 _and(T1, T1, T2);
3066 _sll(T3, SrcR, 24);
3067 _or(T1, T3, T1);
3068 _srl(T4, T1, 16);
3069 _mov(Dest, T4);
3070 return;
3071 }
3072 case IceType_i32: {
3073 auto *T1 = I32Reg();
3074 auto *T2 = I32Reg();
3075 auto *T3 = I32Reg();
3076 auto *T4 = I32Reg();
3077 auto *T5 = I32Reg();
3078 auto *SrcR = legalizeToReg(Src);
3079 _srl(T1, SrcR, 24);
3080 _srl(T2, SrcR, 8);
3081 _andi(T2, T2, 0xFF00);
3082 _or(T1, T2, T1);
3083 _sll(T4, SrcR, 8);
3084 _lui(T3, Ctx->getConstantInt32(255));
3085 _and(T4, T4, T3);
3086 _sll(T5, SrcR, 24);
3087 _or(T4, T5, T4);
3088 _or(T4, T4, T1);
3089 _mov(Dest, T4);
3090 return;
3091 }
3092 case IceType_i64: {
3093 auto *T1 = I32Reg();
3094 auto *T2 = I32Reg();
3095 auto *T3 = I32Reg();
3096 auto *T4 = I32Reg();
3097 auto *T5 = I32Reg();
3098 auto *T6 = I32Reg();
3099 auto *T7 = I32Reg();
3100 auto *T8 = I32Reg();
3101 auto *T9 = I32Reg();
3102 auto *T10 = I32Reg();
3103 auto *T11 = I32Reg();
3104 auto *T12 = I32Reg();
3105 auto *T13 = I32Reg();
3106 auto *T14 = I32Reg();
3107 auto *T15 = I32Reg();
3108 auto *T16 = I32Reg();
3109 auto *T17 = I32Reg();
3110 auto *T18 = I32Reg();
3111 auto *DestLo = llvm::cast<Variable>(loOperand(Dest));
3112 auto *DestHi = llvm::cast<Variable>(hiOperand(Dest));
3113 Src = legalizeUndef(Src);
3114 auto *SrcLoR = legalizeToReg(loOperand(Src));
3115 auto *SrcHiR = legalizeToReg(hiOperand(Src));
3116 _sll(T1, SrcHiR, 8);
3117 _srl(T2, SrcHiR, 24);
3118 _srl(T3, SrcHiR, 8);
3119 _andi(T3, T3, 65280);
Jim Stichnoth 2016/09/27 13:59:53 this magic constant too (I went ahead and fixed it
3120 _lui(T4, Ctx->getConstantInt32(255));
3121 _or(T5, T3, T2);
3122 _and(T6, T1, T4);
3123 _sll(T7, SrcHiR, 24);
3124 _or(T8, T7, T6);
3125 _srl(T9, SrcLoR, 24);
3126 _srl(T10, SrcLoR, 8);
3127 _andi(T11, T10, 0xFF00);
3128 _or(T12, T8, T5);
3129 _or(T13, T11, T9);
3130 _sll(T14, SrcLoR, 8);
3131 _and(T15, T14, T4);
3132 _sll(T16, SrcLoR, 24);
3133 _or(T17, T16, T15);
3134 _or(T18, T17, T13);
3135 _mov(DestLo, T12);
3136 _mov(DestHi, T18);
3137 return;
3138 }
3139 default:
3140 llvm::report_fatal_error("Control flow should never have reached here.");
3141 }
3053 return; 3142 return;
3054 } 3143 }
3055 case Intrinsics::Ctpop: { 3144 case Intrinsics::Ctpop: {
3056 llvm::report_fatal_error("Ctpop should have been prelowered."); 3145 llvm::report_fatal_error("Ctpop should have been prelowered.");
3057 return; 3146 return;
3058 } 3147 }
3059 case Intrinsics::Ctlz: { 3148 case Intrinsics::Ctlz: {
3060 auto *Src = Instr->getArg(0); 3149 auto *Src = Instr->getArg(0);
3061 const Type SrcTy = Src->getType(); 3150 const Type SrcTy = Src->getType();
3062 assert(SrcTy == IceType_i32 || SrcTy == IceType_i64); 3151 assert(SrcTy == IceType_i32 || SrcTy == IceType_i64);
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
4059 Str << "\t.set\t" 4148 Str << "\t.set\t"
4060 << "nomips16\n"; 4149 << "nomips16\n";
4061 } 4150 }
4062 4151
4063 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM]; 4152 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM];
4064 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM]; 4153 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM];
4065 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; 4154 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM];
4066 4155
4067 } // end of namespace MIPS32 4156 } // end of namespace MIPS32
4068 } // end of namespace Ice 4157 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInstMIPS32.h ('k') | tests_lit/assembler/mips32/encoding_intrinsics.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698