Implementing an assembler
As already stated, to get a functioning assembler, you need to provide the implementation of the three previously mentioned classes, starting with the MCCodeEmitter
class.
Providing the MCCodeEmitter class
You already implemented the MCCodeEmitter
class in Chapter 12. However, at that time, we did not show you how to emit a fixup.
First, we start by defining our target-specific fixups. Fixups are simply enumeration values, and their semantics are up to us.
With the limited instruction set of our H2BLB backend, we support only one type of fixup, and the related declaration looks like the following:
enum FixupKind {
FK_H2BLB_PCRel_11 = FirstTargetFixupKind,
LastTargetFixupKind,
NumTargetFixupKinds = LastTargetFixupKind - FirstTargetFixupKind
};
Here, we declare an enumeration whose first entry is our target-specific fixup FK_H2BLB_PCRel_11
value. The naming convention follows the recommended LLVM way to start an enumeration: we...