Skip to content

Commit f94b3c7

Browse files
committed
[llvm-c][MC] Expose color printing via LLVMSetDisasmOptions
1 parent f148d57 commit f94b3c7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llvm/include/llvm-c/Disassembler.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ int LLVMSetDisasmOptions(LLVMDisasmContextRef DC, uint64_t Options);
7979
#define LLVMDisassembler_Option_AsmPrinterVariant 4
8080
/* The option to set comment on instructions */
8181
#define LLVMDisassembler_Option_SetInstrComments 8
82-
/* The option to print latency information alongside instructions */
82+
/* The option to print latency information alongside instructions */
8383
#define LLVMDisassembler_Option_PrintLatency 16
84+
/* The option to print in color */
85+
#define LLVMDisassembler_Option_Color 32
8486

8587
/**
8688
* Dispose of a disassembler context.

llvm/lib/MC/MCDisassembler/Disassembler.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,5 +343,12 @@ int LLVMSetDisasmOptions(LLVMDisasmContextRef DCR, uint64_t Options){
343343
DC->addOptions(LLVMDisassembler_Option_PrintLatency);
344344
Options &= ~LLVMDisassembler_Option_PrintLatency;
345345
}
346+
if (Options & LLVMDisassembler_Option_Color) {
347+
LLVMDisasmContext *DC = static_cast<LLVMDisasmContext *>(DCR);
348+
MCInstPrinter *IP = DC->getIP();
349+
IP->setUseColor(true);
350+
DC->addOptions(LLVMDisassembler_Option_Color);
351+
Options &= ~LLVMDisassembler_Option_Color;
352+
}
346353
return (Options == 0);
347354
}

0 commit comments

Comments
 (0)