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

Side by Side Diff: src/assembler_ia32.h

Issue 673543002: First pass at emitIAS for branches and binding labels (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: check the local labels too Created 6 years, 1 month 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/assembler.h ('k') | src/assembler_ia32.cpp » ('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/assembler_ia32.h - Assembler for x86-32 ------*- C++ -*-===// 1 //===- subzero/src/assembler_ia32.h - Assembler for x86-32 ------*- C++ -*-===//
2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 // 5 //
6 // Modified by the Subzero authors. 6 // Modified by the Subzero authors.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // The Subzero Code Generator 10 // The Subzero Code Generator
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 277
278 public: 278 public:
279 Label() : position_(0), num_unresolved_(0) { 279 Label() : position_(0), num_unresolved_(0) {
280 #ifndef NDEBUG 280 #ifndef NDEBUG
281 for (int i = 0; i < kMaxUnresolvedBranches; i++) { 281 for (int i = 0; i < kMaxUnresolvedBranches; i++) {
282 unresolved_near_positions_[i] = -1; 282 unresolved_near_positions_[i] = -1;
283 } 283 }
284 #endif // !NDEBUG 284 #endif // !NDEBUG
285 } 285 }
286 286
287 ~Label() { 287 ~Label() {}
288
289 void FinalCheck() const {
288 // Assert if label is being destroyed with unresolved branches pending. 290 // Assert if label is being destroyed with unresolved branches pending.
289 assert(!IsLinked()); 291 assert(!IsLinked());
290 assert(!HasNear()); 292 assert(!HasNear());
291 } 293 }
292 294
293 // TODO(jvoung): why are labels offset by this? 295 // TODO(jvoung): why are labels offset by this?
294 static const uint32_t kWordSize = sizeof(uint32_t); 296 static const uint32_t kWordSize = sizeof(uint32_t);
295 297
296 // Returns the position for bound labels (branches that come after this 298 // Returns the position for bound labels (branches that come after this
297 // are considered backward branches). Cannot be used for unused or linked 299 // are considered backward branches). Cannot be used for unused or linked
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 class AssemblerX86 : public Assembler { 358 class AssemblerX86 : public Assembler {
357 AssemblerX86(const AssemblerX86 &) = delete; 359 AssemblerX86(const AssemblerX86 &) = delete;
358 AssemblerX86 &operator=(const AssemblerX86 &) = delete; 360 AssemblerX86 &operator=(const AssemblerX86 &) = delete;
359 361
360 public: 362 public:
361 explicit AssemblerX86(bool use_far_branches = false) : buffer_(*this) { 363 explicit AssemblerX86(bool use_far_branches = false) : buffer_(*this) {
362 // This mode is only needed and implemented for MIPS and ARM. 364 // This mode is only needed and implemented for MIPS and ARM.
363 assert(!use_far_branches); 365 assert(!use_far_branches);
364 (void)use_far_branches; 366 (void)use_far_branches;
365 } 367 }
366 ~AssemblerX86() {} 368 ~AssemblerX86() override;
367 369
368 static const bool kNearJump = true; 370 static const bool kNearJump = true;
369 static const bool kFarJump = false; 371 static const bool kFarJump = false;
370 372
373 Label *GetOrCreateCfgNodeLabel(SizeT NodeNumber);
374 void BindCfgNodeLabel(SizeT NodeNumber) override;
375 Label *GetOrCreateLocalLabel(SizeT Number);
376 void BindLocalLabel(SizeT Number);
377
371 // Operations to emit GPR instructions (and dispatch on operand type). 378 // Operations to emit GPR instructions (and dispatch on operand type).
372 typedef void (AssemblerX86::*TypedEmitGPR)(Type, GPRRegister); 379 typedef void (AssemblerX86::*TypedEmitGPR)(Type, GPRRegister);
373 typedef void (AssemblerX86::*TypedEmitAddr)(Type, const Address &); 380 typedef void (AssemblerX86::*TypedEmitAddr)(Type, const Address &);
374 struct GPREmitterOneOp { 381 struct GPREmitterOneOp {
375 TypedEmitGPR Reg; 382 TypedEmitGPR Reg;
376 TypedEmitAddr Addr; 383 TypedEmitAddr Addr;
377 }; 384 };
378 385
379 typedef void (AssemblerX86::*TypedEmitGPRGPR)(Type, GPRRegister, GPRRegister); 386 typedef void (AssemblerX86::*TypedEmitGPRGPR)(Type, GPRRegister, GPRRegister);
380 typedef void (AssemblerX86::*TypedEmitGPRAddr)(Type, GPRRegister, 387 typedef void (AssemblerX86::*TypedEmitGPRAddr)(Type, GPRRegister,
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 void EmitComplex(Type Ty, int rm, const Operand &operand, 848 void EmitComplex(Type Ty, int rm, const Operand &operand,
842 const Immediate &immediate); 849 const Immediate &immediate);
843 void EmitLabel(Label *label, intptr_t instruction_size); 850 void EmitLabel(Label *label, intptr_t instruction_size);
844 void EmitLabelLink(Label *label); 851 void EmitLabelLink(Label *label);
845 void EmitNearLabelLink(Label *label); 852 void EmitNearLabelLink(Label *label);
846 853
847 void EmitGenericShift(int rm, Type Ty, GPRRegister reg, const Immediate &imm); 854 void EmitGenericShift(int rm, Type Ty, GPRRegister reg, const Immediate &imm);
848 void EmitGenericShift(int rm, Type Ty, const Operand &operand, 855 void EmitGenericShift(int rm, Type Ty, const Operand &operand,
849 GPRRegister shifter); 856 GPRRegister shifter);
850 857
858 typedef std::vector<Label *> LabelVector;
859 // A vector of pool-allocated x86 labels for CFG nodes.
860 LabelVector CfgNodeLabels;
861 // A vector of pool-allocated x86 labels for Local labels.
862 LabelVector LocalLabels;
863
864 Label *GetOrCreateLabel(SizeT Number, LabelVector &Labels);
865
851 AssemblerBuffer buffer_; 866 AssemblerBuffer buffer_;
852 }; 867 };
853 868
854 inline void AssemblerX86::EmitUint8(uint8_t value) { 869 inline void AssemblerX86::EmitUint8(uint8_t value) {
855 buffer_.Emit<uint8_t>(value); 870 buffer_.Emit<uint8_t>(value);
856 } 871 }
857 872
858 inline void AssemblerX86::EmitInt16(int16_t value) { 873 inline void AssemblerX86::EmitInt16(int16_t value) {
859 buffer_.Emit<int16_t>(value); 874 buffer_.Emit<int16_t>(value);
860 } 875 }
(...skipping 14 matching lines...) Expand all
875 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) { 890 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) {
876 buffer_.EmitFixup(fixup); 891 buffer_.EmitFixup(fixup);
877 } 892 }
878 893
879 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); } 894 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); }
880 895
881 } // end of namespace x86 896 } // end of namespace x86
882 } // end of namespace Ice 897 } // end of namespace Ice
883 898
884 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_ 899 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_
OLDNEW
« no previous file with comments | « src/assembler.h ('k') | src/assembler_ia32.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698