llvm-project/llvm/lib/Target/X86/MCTargetDesc
Shengchen Kan b78c3c89c2 [X86][MC][NFC] Reduce the parameters of functions in X86MCCodeEmitter(Part III)
Summary:
When we encode an instruction, we need to know the number of bytes being
emitted to determine the fixups in `X86MCCodeEmitter::emitImmediate`.
There are only two callers for `emitImmediate`: `emitMemModRMByte` and
`encodeInstruction`.

Before this patch, we kept track of the current byte being emitted
by passing a reference parameter `CurByte` across all the `emit*`
funtions, which is ugly and unnecessary. For example, we don't have any
fixups when emitting prefixes, so we don't need to track this value.

In this patch, we use `StartByte` to record the initial status of the
streamer, and use `OS.tell()` to get the current status of the streamer
when we need to know the number of bytes being emitted. On one hand,
this eliminates the parameter `CurByte` for most `emit*` functions, on
the other hand, this make things clear: Only pass the parameter when we
really need it.

Reviewers: craig.topper, pengfei, MaskRay

Reviewed By: craig.topper, MaskRay

Subscribers: hiraditya, llvm-commits, annita.zhang

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78419
2020-04-20 10:03:41 +08:00
..
CMakeLists.txt [X86] Move X86ShuffleDecode.cpp/h into MCTargetDesc and remove X86Utils library. NFC 2020-04-13 10:14:08 -07:00
LLVMBuild.txt [X86] Move X86ShuffleDecode.cpp/h into MCTargetDesc and remove X86Utils library. NFC 2020-04-13 10:14:08 -07:00
X86ATTInstPrinter.cpp [MCInstPrinter] Add parameter `Address` to MCInstPrinter::printAliasInstr. NFC 2020-03-27 00:03:32 -07:00
X86ATTInstPrinter.h [MCInstPrinter] Add parameter `Address` to printCustomAliasOperand. NFC 2020-03-27 00:38:20 -07:00
X86AsmBackend.cpp [MC][X86] Disable branch align in non-text section 2020-04-18 14:41:25 +08:00
X86BaseInfo.h [X86] Add interface X86II::isPseudo 2020-04-16 12:40:17 +08:00
X86ELFObjectWriter.cpp [MC][X86] Make .reloc support arbitrary relocation types 2020-03-27 13:33:15 -07:00
X86FixupKinds.h
X86InstComments.cpp [X86] Move X86ShuffleDecode.cpp/h into MCTargetDesc and remove X86Utils library. NFC 2020-04-13 10:14:08 -07:00
X86InstComments.h [X86] Move InstPrinter files to MCTargetDesc. NFC 2019-05-10 23:24:38 +00:00
X86InstPrinterCommon.cpp [X86InstPrinter] Change printPCRelImm to print the target address in hexadecimal form 2020-03-26 08:28:59 -07:00
X86InstPrinterCommon.h [MCInstPrinter] Pass `Address` parameter to MCOI::OPERAND_PCREL typed operands. NFC 2020-03-26 08:21:15 -07:00
X86IntelInstPrinter.cpp [MCInstPrinter] Add parameter `Address` to MCInstPrinter::printAliasInstr. NFC 2020-03-27 00:03:32 -07:00
X86IntelInstPrinter.h [MCInstPrinter] Add parameter `Address` to printCustomAliasOperand. NFC 2020-03-27 00:38:20 -07:00
X86MCAsmInfo.cpp [MC] Default MCAsmInfo::UseIntegratedAssembler to true 2020-04-11 10:13:52 -07:00
X86MCAsmInfo.h [ms] [llvm-ml] Add a draft MASM parser 2020-02-16 12:30:46 -05:00
X86MCCodeEmitter.cpp [X86][MC][NFC] Reduce the parameters of functions in X86MCCodeEmitter(Part III) 2020-04-20 10:03:41 +08:00
X86MCExpr.h [X86] Move InstPrinter files to MCTargetDesc. NFC 2019-05-10 23:24:38 +00:00
X86MCTargetDesc.cpp [ms] [llvm-ml] Add a draft MASM parser 2020-02-16 12:30:46 -05:00
X86MCTargetDesc.h X86MCTargetDesc.h - remove unnecessary includes and forward declarations. NFC. 2020-04-19 14:29:35 +01:00
X86MachObjectWriter.cpp [MC] Minor cleanup to MCFixup::Kind handling. NFC. 2019-08-23 01:00:55 +00:00
X86ShuffleDecode.cpp [X86] Move X86ShuffleDecode.cpp/h into MCTargetDesc and remove X86Utils library. NFC 2020-04-13 10:14:08 -07:00
X86ShuffleDecode.h [X86] Move X86ShuffleDecode.cpp/h into MCTargetDesc and remove X86Utils library. NFC 2020-04-13 10:14:08 -07:00
X86TargetStreamer.h
X86WinCOFFObjectWriter.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
X86WinCOFFStreamer.cpp [MC] Avoid crashes from improperly nested or wrong target .seh_handlerdata directives 2019-08-30 22:25:55 +00:00
X86WinCOFFTargetStreamer.cpp [MC] Add MCStreamer::emitInt{8,16,32,64} 2020-02-29 09:40:21 -08:00