Henning Thielemann
2012-May-23 22:38 UTC
[LLVMdev] tblgen for generation of Haskell bindings to LLVM intrinsics
I want to generate Haskell bindings to LLVM intrinsics. In a first attempt I wrote a little parser that reads IntrinsicsX86.td and outputs a Haskell module. E.g. the definition def int_x86_avx_max_ps_256 : GCCBuiltin<"__builtin_ia32_maxps256">, Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8f32_ty], [IntrNoMem]>; is turned into maxpd256 :: Ext.T (V4Double -> V4Double -> LLVM.CodeGenFunction r V4Double) maxpd256 = Ext.intrinsic ExtX86.avx "max.pd.256" This works for the flat structure of IntrinsicsX86.td, but e.g. IntrinsicsPowerPC.td uses tablegen classes. Now I wonder whether it is better to use tablegen to generate the Haskell code. The tblgen man page says, that tablegen emits C++. This would not be a big problem, since I could let it write C++ code that in turn writes Haskell code. Unfortunately the section "http://llvm.org/docs/TableGenFundamentals.html#backends" is not yet written. Is it possible to use the llvm-tblgen binary without modification or do I have to extend llvm-tblgen or do I have to write my own C++ code that uses some of the functions from the tblgen library? Are there any (simple) examples of custom tblgen backends?
Sebastian Redl
2012-May-24 08:37 UTC
[LLVMdev] tblgen for generation of Haskell bindings to LLVM intrinsics
On 24.05.2012 00:38, Henning Thielemann wrote:> I want to generate Haskell bindings to LLVM intrinsics. In a first attempt I > wrote a little parser that reads IntrinsicsX86.td and outputs a Haskell module. > > E.g. the definition > > def int_x86_avx_max_ps_256 : GCCBuiltin<"__builtin_ia32_maxps256">, > Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, > llvm_v8f32_ty], [IntrNoMem]>; > > is turned into > > maxpd256 :: Ext.T (V4Double -> V4Double -> LLVM.CodeGenFunction r V4Double) > maxpd256 = Ext.intrinsic ExtX86.avx "max.pd.256" > > > This works for the flat structure of IntrinsicsX86.td, but e.g. > IntrinsicsPowerPC.td uses tablegen classes. > > Now I wonder whether it is better to use tablegen to generate the Haskell code. > The tblgen man page says, that tablegen emits C++.It emits whatever text a particular backend decides to spit out. You would have to write your own backend anyway, so you can just make it emit Haskell code. Writing a backend isn't hard - a rather simple one to look at would be Clang's diagnostic generator (it's in the Clang tree). Sebastian
Maybe Matching Threads
- Strange types on x86 vcvtph2ps and vcvtps2ph intrinsics
- ANN: HaLVM 1.0: the Haskell Lightweight Virtual Machine
- [UNFINISHED PATCHES] Make optional arguments work in Haskell
- Haskell bindings for libvirt
- [LLVMdev] glasgow haskell appears to be adopting LLVM