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

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 401533002: Lower byte swap intrinsic. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: rebased Created 6 years, 5 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/IceTargetLoweringX8632.h ('k') | tests_lit/llvm2ice_tests/nacl-other-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 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===//
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 // This file implements the TargetLoweringX8632 class, which 10 // This file implements the TargetLoweringX8632 class, which
(...skipping 2578 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 OperandX8632Mem *Addr = FormMemoryOperand(Ptr, IceType_f64); 2589 OperandX8632Mem *Addr = FormMemoryOperand(Ptr, IceType_f64);
2590 _storeq(T, Addr); 2590 _storeq(T, Addr);
2591 _mfence(); 2591 _mfence();
2592 return; 2592 return;
2593 } 2593 }
2594 InstStore *Store = InstStore::create(Func, Value, Ptr); 2594 InstStore *Store = InstStore::create(Func, Value, Ptr);
2595 lowerStore(Store); 2595 lowerStore(Store);
2596 _mfence(); 2596 _mfence();
2597 return; 2597 return;
2598 } 2598 }
2599 case Intrinsics::Bswap: 2599 case Intrinsics::Bswap: {
2600 Func->setError("Unhandled intrinsic"); 2600 Variable *Dest = Instr->getDest();
2601 Operand *Val = Instr->getArg(0);
2602 // In 32-bit mode, bswap only works on 32-bit arguments, and the
2603 // argument must be a register. Use rotate left for 16-bit bswap.
2604 if (Val->getType() == IceType_i64) {
2605 Variable *T_Lo = legalizeToVar(loOperand(Val));
2606 Variable *T_Hi = legalizeToVar(hiOperand(Val));
2607 Variable *DestLo = llvm::cast<Variable>(loOperand(Dest));
2608 Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest));
2609 _bswap(T_Lo);
2610 _bswap(T_Hi);
2611 _mov(DestLo, T_Hi);
2612 _mov(DestHi, T_Lo);
2613 } else if (Val->getType() == IceType_i32) {
2614 Variable *T = legalizeToVar(Val);
2615 _bswap(T);
2616 _mov(Dest, T);
2617 } else {
2618 assert(Val->getType() == IceType_i16);
2619 Val = legalize(Val);
2620 Constant *Eight = Ctx->getConstantInt(IceType_i16, 8);
2621 Variable *T = NULL;
2622 _mov(T, Val);
2623 _rol(T, Eight);
2624 _mov(Dest, T);
2625 }
2601 return; 2626 return;
2627 }
2602 case Intrinsics::Ctpop: { 2628 case Intrinsics::Ctpop: {
2603 Variable *Dest = Instr->getDest(); 2629 Variable *Dest = Instr->getDest();
2604 Operand *Val = Instr->getArg(0); 2630 Operand *Val = Instr->getArg(0);
2605 InstCall *Call = makeHelperCall(Val->getType() == IceType_i64 ? 2631 InstCall *Call = makeHelperCall(Val->getType() == IceType_i64 ?
2606 "__popcountdi2" : "__popcountsi2", Dest, 1); 2632 "__popcountdi2" : "__popcountsi2", Dest, 1);
2607 Call->addArg(Val); 2633 Call->addArg(Val);
2608 lowerCall(Call); 2634 lowerCall(Call);
2609 // The popcount helpers always return 32-bit values, while the intrinsic's 2635 // The popcount helpers always return 32-bit values, while the intrinsic's
2610 // signature matches the native POPCNT instruction and fills a 64-bit reg 2636 // signature matches the native POPCNT instruction and fills a 64-bit reg
2611 // (in 64-bit mode). Thus, clear the upper bits of the dest just in case 2637 // (in 64-bit mode). Thus, clear the upper bits of the dest just in case
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3717 for (SizeT i = 0; i < Size; ++i) { 3743 for (SizeT i = 0; i < Size; ++i) {
3718 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 3744 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
3719 } 3745 }
3720 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 3746 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
3721 } 3747 }
3722 Str << "\t" << (IsInternal ? ".local" : ".global") << "\t" << MangledName 3748 Str << "\t" << (IsInternal ? ".local" : ".global") << "\t" << MangledName
3723 << "\n"; 3749 << "\n";
3724 } 3750 }
3725 3751
3726 } // end of namespace Ice 3752 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLoweringX8632.h ('k') | tests_lit/llvm2ice_tests/nacl-other-intrinsics.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698