Re: A small LLVM tutorial: debugging information

Vincent Belliard <vincent@famillebelliard.fr>
Thu, 31 May 2012 00:10:16 -0700 (PDT)

          From comp.compilers

Related articles
A small LLVM tutorial: debugging information vincent@famillebelliard.fr (vincent_belliard) (2012-05-25)
Re: A small LLVM tutorial: debugging information echristo@gmail.com (Eric Christopher) (2012-05-29)
Re: A small LLVM tutorial: debugging information vincent@famillebelliard.fr (Vincent Belliard) (2012-05-31)
| List of all articles for this month |
From: Vincent Belliard <vincent@famillebelliard.fr>
Newsgroups: comp.compilers
Date: Thu, 31 May 2012 00:10:16 -0700 (PDT)
Organization: Compilers Central
References: 12-05-029
Keywords: LLVM
Posted-Date: 01 Jun 2012 01:26:29 EDT

Yes, of course, using the LLVM builder is much easier (or, at least,
quicker to start). In my case, I needed to do all with my language
Entity so I couldn't use the builders. I did my own which are simpler
than the LLVM ones as they cover only what I needed.


This small tutorial is still useful if you use the builders. May some
topics won't be necessary but it's always good to understand deeply
what you are using.


Nevertheless, in the next version, I will add your comment.


vincent




PS: I made a very small language close to C but close to LLVM. It's very
useful to write small libraries functions with a deep control over the
generated code without writting directly in LLVM.
Here is an example of a string compare with my zero padded strings:


i1 @equals_string_contents(%_self: %string_content*, %_cmp: %string_content*)
{
var size_ref: i64 = %_self->size ;
var size_cmp: i64 = %_cmp->size ;
if (size_ref ne size_cmp) return 0 ;
var count: i64 = size_ref >> 3 ;
var ref: i64* = <i64*>%_self->data ;
var cmp: i64* = <i64*>%_cmp->data ;
loop
{
phi phi_count: i64 = count | next_count ;
phi phi_ref: i64* = ref | next_ref ;
phi phi_cmp: i64* = cmp | next_cmp ;
if (phi_count eq 0) return 1 ;
if (*phi_ref ne *phi_cmp) return 0 ;
var next_count: i64 = phi_count - 1 ;
var next_ref: i64* = phi_ref + 1 ;
var next_cmp: i64* = phi_cmp + 1 ;
}
}



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.