2011-09-24 4 views
0

dragonegg에있을 때 llvm-gcc-emit-llvm를 실행할 수 있고 llvm 비트 코드를 생성했습니다. 이제 dragonegg를 플러그인 (gcc -fplugin=dragonegg.so)으로 사용할 때 더 이상 그런 옵션을 찾을 수 없습니다. 내가 찾은 유일한 것은 LLVM IR을 생성하는 것이 었습니다. 어떻게 비트 코드를 생성 할 수 있습니까?dragonegg에서 비트 코드를 생성하는 방법

GCC는 4.6, LLVM과 Dragonegg는 현재 SVN입니다. 그리고 clang을 사용하는 것은 C++ 11 지원이 약하기 때문에 옵션이 아닙니다.

답변

1

는 LLVM의 비트 코드를 출력하는 것은 가능하지 않는 것 때문에 더 이상 나는 그 다음주는 LLVM-으로 적외선을 공급하는 파이썬 스크립트를 작성 나 비트 코드. 성능 측면에서 이것은 재앙이지만, 적어도 작동합니다. 에서 [문서]에서

#/usr/bin/env python 

import sys, subprocess 

args = list(sys.argv) 
del args[0] # Remove our exec name 
compiler = args[0] 
del args[0] # Remove the compile name 

compileArguments = [compiler] 
outputFile = '' 

foundFile = False 

for arg in args: 
if arg.startswith('-o'): 
    foundFile = True 
elif foundFile: 
    outputFile = arg 
    foundFile = False 
    arg = "/dev/stdout" 

compileArguments.append(arg) 

compileProcess = subprocess.Popen(compileArguments, stdout=subprocess.PIPE) 
asbin = 'llvm-as' 

ir2bcProcess = subprocess.Popen([asbin, '-f', '-o=' + outputFile], stdin=compileProcess.stdout) 

stdout, stderr = ir2bcProcess.communicate() 

compileProcess.wait() 
ir2bcProcess.wait() 
0

:

 
-fplugin-arg-dragonegg-emit-ir 
-flto 
    Output LLVM IR rather than target assembler. You need to use -S with this, 
    since otherwise GCC will pass the output to the system assembler (these don't 
    usually understand LLVM IR). It would be nice to fix this and have the option 
    work with -c too but it's not clear how. If you plan to read the IR then you 
    probably want to use the -fverbose-asm flag as well (see below). 
+0

은 (http://llvm.org/docs/BitCodeFormat.html는) : 일반적으로 (또한, 때로는 anachronistically 바이트 코드라고도 함) LLVM 비트 코드 파일 형식으로 알려진 사실은 두 가지입니다 : 비트 스트림 컨테이너 형식 및 LLVM IR의 컨테이너 형식으로의 인코딩. – abergmeier

+0

IR을 얻을 수있는 동안 컨테이너도 필요합니다. 게다가 이미 LLVM IR을 시도했지만 다른 LLVM 도구로 인식되기 시작하지 않습니다. – abergmeier

관련 문제