+ struct GasBugWorkaroundEmitter : public MachineCodeEmitter {
+ GasBugWorkaroundEmitter(std::ostream& o)
+ : O(o), OldFlags(O.flags()), firstByte(true) {
+ O << std::hex;
+ }
+
+ ~GasBugWorkaroundEmitter() {
+ O.flags(OldFlags);
+ O << "\t# ";
+ }
+
+ virtual void emitByte(unsigned char B) {
+ if (!firstByte) O << "\n\t";
+ firstByte = false;
+ O << ".byte 0x" << (unsigned) B;
+ }
+
+ // These should never be called
+ virtual void emitWord(unsigned W) { assert(0); }
+ virtual uint64_t getGlobalValueAddress(GlobalValue *V) { assert(0); }
+ virtual uint64_t getGlobalValueAddress(const std::string &Name) { assert(0); }
+ virtual uint64_t getConstantPoolEntryAddress(unsigned Index) { assert(0); }
+ virtual uint64_t getCurrentPCValue() { assert(0); }
+ virtual uint64_t forceCompilationOf(Function *F) { assert(0); }
+
+ private:
+ std::ostream& O;
+ std::ios::fmtflags OldFlags;
+ bool firstByte;
+ };
+