Commit b1a7a245 authored by Shengchen Kan's avatar Shengchen Kan
Browse files

[NFC][MC] Rename alignBranches* to emitInstruction*

alignBranches is X86 specific, change the name in a
more general one since other target can do some state
chang before and after emitting the instruction.
parent a2923b2a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -51,10 +51,10 @@ public:
  virtual bool allowAutoPadding() const { return false; }

  /// Give the target a chance to manipulate state related to instruction
  /// alignment (e.g. padding for optimization) before and after actually
  /// emitting the instruction.
  virtual void alignBranchesBegin(MCObjectStreamer &OS, const MCInst &Inst) {}
  virtual void alignBranchesEnd(MCObjectStreamer &OS, const MCInst &Inst) {}
  /// alignment (e.g. padding for optimization), instruction relaxablility, etc.
  /// before and after actually emitting the instruction.
  virtual void emitInstructionBegin(MCObjectStreamer &OS, const MCInst &Inst) {}
  virtual void emitInstructionEnd(MCObjectStreamer &OS, const MCInst &Inst) {}

  /// lifetime management
  virtual void reset() {}
+2 −2
Original line number Diff line number Diff line
@@ -367,9 +367,9 @@ bool MCObjectStreamer::mayHaveInstructions(MCSection &Sec) const {

void MCObjectStreamer::emitInstruction(const MCInst &Inst,
                                       const MCSubtargetInfo &STI) {
  getAssembler().getBackend().alignBranchesBegin(*this, Inst);
  getAssembler().getBackend().emitInstructionBegin(*this, Inst);
  emitInstructionImpl(Inst, STI);
  getAssembler().getBackend().alignBranchesEnd(*this, Inst);
  getAssembler().getBackend().emitInstructionEnd(*this, Inst);
}

void MCObjectStreamer::emitInstructionImpl(const MCInst &Inst,
+6 −6
Original line number Diff line number Diff line
@@ -161,8 +161,8 @@ public:
  }

  bool allowAutoPadding() const override;
  void alignBranchesBegin(MCObjectStreamer &OS, const MCInst &Inst) override;
  void alignBranchesEnd(MCObjectStreamer &OS, const MCInst &Inst) override;
  void emitInstructionBegin(MCObjectStreamer &OS, const MCInst &Inst) override;
  void emitInstructionEnd(MCObjectStreamer &OS, const MCInst &Inst) override;

  unsigned getNumFixupKinds() const override {
    return X86::NumTargetFixupKinds;
@@ -512,7 +512,7 @@ bool X86AsmBackend::needAlignInst(const MCInst &Inst) const {
}

/// Insert BoundaryAlignFragment before instructions to align branches.
void X86AsmBackend::alignBranchesBegin(MCObjectStreamer &OS,
void X86AsmBackend::emitInstructionBegin(MCObjectStreamer &OS,
                                       const MCInst &Inst) {
  if (!needAlign(OS))
    return;
@@ -538,7 +538,7 @@ void X86AsmBackend::alignBranchesBegin(MCObjectStreamer &OS,
    //
    // Do nothing here since we already inserted a BoudaryAlign fragment when
    // we met the first instruction in the fused pair and we'll tie them
    // together in alignBranchesEnd.
    // together in emitInstructionEnd.
    //
    // Note: When there is at least one fragment, such as MCAlignFragment,
    // inserted after the previous instruction, e.g.
@@ -564,7 +564,7 @@ void X86AsmBackend::alignBranchesBegin(MCObjectStreamer &OS,
}

/// Set the last fragment to be aligned for the BoundaryAlignFragment.
void X86AsmBackend::alignBranchesEnd(MCObjectStreamer &OS, const MCInst &Inst) {
void X86AsmBackend::emitInstructionEnd(MCObjectStreamer &OS, const MCInst &Inst) {
  if (!needAlign(OS))
    return;