Created
October 12, 2013 09:48
-
-
Save o11c/6948059 to your computer and use it in GitHub Desktop.
A method of detecting whether, for a single target, LLVM supports its AsmParser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#define current_target X86 | |
#define current_target bogus | |
#define __STDC_LIMIT_MACROS | |
#define __STDC_CONSTANT_MACROS | |
#include "llvm-c/Target.h" | |
#include <stdbool.h> | |
#define JOIN2(a, b) a ## b | |
#define JOIN(a, b) JOIN2(a, b) | |
#define TARGET_VAR(t) JOIN(t, _printer) | |
int main() | |
{ | |
// no initializer needed | |
bool TARGET_VAR(current_target); | |
{ | |
#define LLVM_ASM_PARSER(target) \ | |
bool TARGET_VAR(target) = false; | |
#include "llvm/Config/AsmParsers.def" | |
TARGET_VAR(current_target) = true; | |
#define LLVM_ASM_PARSER(target) \ | |
if (TARGET_VAR(target)) \ | |
LLVMInitialize ## target ## AsmParser(); | |
#include "llvm/Config/AsmParsers.def" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment