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

Side by Side Diff: src/IceTargetLoweringX86Base.h

Issue 1273153002: Subzero. Native 64-bit int arithmetic on x86-64. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Removes the x8664-specific xtest target. Created 5 years, 4 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/IceTargetLoweringX86Base.h - x86 lowering ----*- C++ -*-===// 1 //===- subzero/src/IceTargetLoweringX86Base.h - x86 lowering ----*- C++ -*-===//
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return TypeToRegisterSet[Ty]; 76 return TypeToRegisterSet[Ty];
77 } 77 }
78 bool hasFramePointer() const override { return IsEbpBasedFrame; } 78 bool hasFramePointer() const override { return IsEbpBasedFrame; }
79 SizeT getFrameOrStackReg() const override { 79 SizeT getFrameOrStackReg() const override {
80 return IsEbpBasedFrame ? Traits::RegisterSet::Reg_ebp 80 return IsEbpBasedFrame ? Traits::RegisterSet::Reg_ebp
81 : Traits::RegisterSet::Reg_esp; 81 : Traits::RegisterSet::Reg_esp;
82 } 82 }
83 size_t typeWidthInBytesOnStack(Type Ty) const override { 83 size_t typeWidthInBytesOnStack(Type Ty) const override {
84 // Round up to the next multiple of 4 bytes. In particular, i1, 84 // Round up to the next multiple of 4 bytes. In particular, i1,
85 // i8, and i16 are rounded up to 4 bytes. 85 // i8, and i16 are rounded up to 4 bytes.
86 // TODO(jpp): this needs to round to multiples of 8 bytes in x86-64. 86 // TODO(jpp): this needs to round to multiples of 8 bytes in x86-64.
Jim Stichnoth 2015/08/10 16:08:05 remove TODO?
John 2015/08/10 20:41:17 Done.
87 return (typeWidthInBytes(Ty) + 3) & ~3; 87 const uint32_t WordSizeInBytes = typeWidthInBytes(Traits::WordType);
88 return (typeWidthInBytes(Ty) + WordSizeInBytes - 1) &
89 ~(WordSizeInBytes - 1);
88 } 90 }
89 91
90 SizeT getMinJumpTableSize() const override { return 4; } 92 SizeT getMinJumpTableSize() const override { return 4; }
91 93
92 void emitVariable(const Variable *Var) const override; 94 void emitVariable(const Variable *Var) const override;
93 95
94 const char *getConstantPrefix() const final { return "$"; } 96 const char *getConstantPrefix() const final { return "$"; }
95 void emit(const ConstantUndef *C) const final; 97 void emit(const ConstantUndef *C) const final;
96 void emit(const ConstantInteger32 *C) const final; 98 void emit(const ConstantInteger32 *C) const final;
97 void emit(const ConstantInteger64 *C) const final; 99 void emit(const ConstantInteger64 *C) const final;
98 void emit(const ConstantFloat *C) const final; 100 void emit(const ConstantFloat *C) const final;
99 void emit(const ConstantDouble *C) const final; 101 void emit(const ConstantDouble *C) const final;
100 102
101 void initNodeForLowering(CfgNode *Node) override; 103 void initNodeForLowering(CfgNode *Node) override;
102 /// Ensure that a 64-bit Variable has been split into 2 32-bit 104 /// x86-32: Ensure that a 64-bit Variable has been split into 2 32-bit
103 /// Variables, creating them if necessary. This is needed for all 105 /// Variables, creating them if necessary. This is needed for all
104 /// I64 operations, and it is needed for pushing F64 arguments for 106 /// I64 operations, and it is needed for pushing F64 arguments for
105 /// function calls using the 32-bit push instruction (though the 107 /// function calls using the 32-bit push instruction (though the
106 /// latter could be done by directly writing to the stack). 108 /// latter could be done by directly writing to the stack).
107 void split64(Variable *Var); 109 ///
108 Operand *loOperand(Operand *Operand); 110 /// x86-64: Complains loudly if invoked because the cpu can handle
109 Operand *hiOperand(Operand *Operand); 111 /// 64-bit types natively.
112 template <typename T = Traits>
113 typename std::enable_if<!T::Is64Bit, void>::type split64(Variable *Var);
114 template <typename T = Traits>
115 typename std::enable_if<T::Is64Bit, void>::type split64(Variable *) {
116 llvm::report_fatal_error(
117 "Hey, yo! This is x86-64. Watcha doin'? (split64)");
Jim Stichnoth 2015/08/10 16:08:05 Made me laugh, but... more professional strings fo
John 2015/08/10 20:41:17 :( but Google is known for these *Googley** string
Jim Stichnoth 2015/08/11 16:01:36 No **real** opposition.
118 }
119
120 template <typename T = Traits>
121 typename std::enable_if<!T::Is64Bit, Operand>::type *
122 loOperand(Operand *Operand);
123 template <typename T = Traits>
124 typename std::enable_if<T::Is64Bit, Operand>::type *loOperand(Operand *) {
125 llvm::report_fatal_error(
126 "Hey, yo! This is x86-64. Watcha doin'? (loOperand)");
127 }
128
129 template <typename T = Traits>
130 typename std::enable_if<!T::Is64Bit, Operand>::type *
131 hiOperand(Operand *Operand);
132 template <typename T = Traits>
133 typename std::enable_if<T::Is64Bit, Operand>::type *hiOperand(Operand *) {
134 llvm::report_fatal_error(
135 "Hey, yo! This is x86-64. Watcha doin'? (hiOperand)");
136 }
137
110 void finishArgumentLowering(Variable *Arg, Variable *FramePtr, 138 void finishArgumentLowering(Variable *Arg, Variable *FramePtr,
111 size_t BasicFrameOffset, size_t &InArgsSizeBytes); 139 size_t BasicFrameOffset, size_t &InArgsSizeBytes);
112 typename Traits::Address stackVarToAsmOperand(const Variable *Var) const; 140 typename Traits::Address stackVarToAsmOperand(const Variable *Var) const;
113 141
114 typename Traits::InstructionSet getInstructionSet() const { 142 typename Traits::InstructionSet getInstructionSet() const {
115 return InstructionSet; 143 return InstructionSet;
116 } 144 }
117 Operand *legalizeUndef(Operand *From, int32_t RegNum = Variable::NoRegister); 145 Operand *legalizeUndef(Operand *From, int32_t RegNum = Variable::NoRegister);
118 146
119 protected: 147 protected:
120 explicit TargetX86Base(Cfg *Func); 148 explicit TargetX86Base(Cfg *Func);
121 149
122 void postLower() override; 150 void postLower() override;
123 151
124 void lowerAlloca(const InstAlloca *Inst) override; 152 void lowerAlloca(const InstAlloca *Inst) override;
125 void lowerArithmetic(const InstArithmetic *Inst) override; 153 void lowerArithmetic(const InstArithmetic *Inst) override;
126 void lowerAssign(const InstAssign *Inst) override; 154 void lowerAssign(const InstAssign *Inst) override;
127 void lowerBr(const InstBr *Inst) override; 155 void lowerBr(const InstBr *Inst) override;
128 void lowerCast(const InstCast *Inst) override; 156 void lowerCast(const InstCast *Inst) override;
129 void lowerExtractElement(const InstExtractElement *Inst) override; 157 void lowerExtractElement(const InstExtractElement *Inst) override;
130 void lowerFcmp(const InstFcmp *Inst) override; 158 void lowerFcmp(const InstFcmp *Inst) override;
131 void lowerIcmp(const InstIcmp *Inst) override; 159 void lowerIcmp(const InstIcmp *Inst) override;
160 /// Complains loudly if invoked because the cpu can handle 64-bit types
161 /// natively.
162 template <typename T = Traits>
163 typename std::enable_if<T::Is64Bit, void>::type
164 lowerIcmp64(const InstIcmp *) {
165 llvm::report_fatal_error(
166 "Hey, yo! This is x86-64. Watcha doin'? (lowerIcmp64)");
167 }
168 /// x86lowerIcmp64 handles 64-bit icmp lowering.
169 template <typename T = Traits>
170 typename std::enable_if<!T::Is64Bit, void>::type
171 lowerIcmp64(const InstIcmp *Inst);
172
132 void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override; 173 void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override;
133 void lowerInsertElement(const InstInsertElement *Inst) override; 174 void lowerInsertElement(const InstInsertElement *Inst) override;
134 void lowerLoad(const InstLoad *Inst) override; 175 void lowerLoad(const InstLoad *Inst) override;
135 void lowerPhi(const InstPhi *Inst) override; 176 void lowerPhi(const InstPhi *Inst) override;
136 void lowerSelect(const InstSelect *Inst) override; 177 void lowerSelect(const InstSelect *Inst) override;
137 void lowerStore(const InstStore *Inst) override; 178 void lowerStore(const InstStore *Inst) override;
138 void lowerSwitch(const InstSwitch *Inst) override; 179 void lowerSwitch(const InstSwitch *Inst) override;
139 void lowerUnreachable(const InstUnreachable *Inst) override; 180 void lowerUnreachable(const InstUnreachable *Inst) override;
140 void lowerOther(const Inst *Instr) override; 181 void lowerOther(const Inst *Instr) override;
141 void lowerRMW(const typename Traits::Insts::FakeRMW *RMW); 182 void lowerRMW(const typename Traits::Insts::FakeRMW *RMW);
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 664 }
624 665
625 BoolFolding FoldingInfo; 666 BoolFolding FoldingInfo;
626 }; 667 };
627 } // end of namespace X86Internal 668 } // end of namespace X86Internal
628 } // end of namespace Ice 669 } // end of namespace Ice
629 670
630 #include "IceTargetLoweringX86BaseImpl.h" 671 #include "IceTargetLoweringX86BaseImpl.h"
631 672
632 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H 673 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698