From owner-svn-soc-all@FreeBSD.ORG Tue Aug 12 23:03:12 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C2BBC192 for ; Tue, 12 Aug 2014 23:03:12 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AF75223E7 for ; Tue, 12 Aug 2014 23:03:12 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7CN3CRj073096 for ; Tue, 12 Aug 2014 23:03:12 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s7CN3BRY073093 for svn-soc-all@FreeBSD.org; Tue, 12 Aug 2014 23:03:11 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 12 Aug 2014 23:03:11 GMT Message-Id: <201408122303.s7CN3BRY073093@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r272310 - soc2014/dpl/llvm_examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Aug 2014 23:03:12 -0000 Author: dpl Date: Tue Aug 12 23:03:11 2014 New Revision: 272310 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272310 Log: Added necessary boilerplate to get it working without includes. Added: soc2014/dpl/llvm_examples/structs.ll Modified: soc2014/dpl/llvm_examples/structs.c Modified: soc2014/dpl/llvm_examples/structs.c ============================================================================== --- soc2014/dpl/llvm_examples/structs.c Tue Aug 12 22:38:52 2014 (r272309) +++ soc2014/dpl/llvm_examples/structs.c Tue Aug 12 23:03:11 2014 (r272310) @@ -1,11 +1,34 @@ -#include -#include -#include -#include +#include #include +struct mbuf { + struct mbuf *m_next; + struct mbuf *m_nextpkt; + void *m_data; + int m_len; /* length in this mbuf */ + int m_flags; + struct { + struct ifnet *rcvif; + int len; /* total packet len */ + SLIST_HEAD (packet_tags, m_tag) tags; + } m_pkthdr; + struct skbuf *m_skb; + + /* + * in-stack mbuffers point to an external buffer, + * the two variables below contain base and size, + * and have M_STACK set in m_flags. + * Buffers from the heap have __m_extbuf = (char *)m + MSIZE + */ + void *__m_extbuf; /* external buffer base */ + int __m_extlen; /* data in ext buffer */ + void (*__m_callback)(struct mbuf *, int); + void *__m_peer; /* argument attached to the mbuf */ +}; + struct mbuf gmbuf; +#define mtod(m, t) ((t)((m)->m_data)) int main() @@ -15,7 +38,7 @@ struct ip *ip = mtod(m, struct ip *); m = &gmbuf; - pktlen = m->pkthdr.len; + pktlen = m->m_pkthdr.len; return (0); } Added: soc2014/dpl/llvm_examples/structs.ll ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2014/dpl/llvm_examples/structs.ll Tue Aug 12 23:03:11 2014 (r272310) @@ -0,0 +1,41 @@ +; ModuleID = 'structs.c' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-freebsd11.0" + +%struct.mbuf = type { %struct.mbuf*, %struct.mbuf*, i8*, i32, i32, %struct.anon, %struct.skbuf*, i8*, i32, void (%struct.mbuf*, i32)*, i8* } +%struct.anon = type { %struct.ifnet*, i32, %struct.packet_tags } +%struct.ifnet = type opaque +%struct.packet_tags = type { %struct.m_tag* } +%struct.m_tag = type opaque +%struct.skbuf = type opaque +%struct.ip = type opaque + +@gmbuf = common global %struct.mbuf zeroinitializer, align 8 + +; Function Attrs: nounwind uwtable +define i32 @main() #0 { +entry: + %retval = alloca i32, align 4 + %m = alloca %struct.mbuf*, align 8 + %pktlen = alloca i32, align 4 + %ip = alloca %struct.ip*, align 8 + store i32 0, i32* %retval + %0 = load %struct.mbuf** %m, align 8 + %m_data = getelementptr inbounds %struct.mbuf* %0, i32 0, i32 2 + %1 = load i8** %m_data, align 8 + %2 = bitcast i8* %1 to %struct.ip* + store %struct.ip* %2, %struct.ip** %ip, align 8 + store %struct.mbuf* @gmbuf, %struct.mbuf** %m, align 8 + %3 = load %struct.mbuf** %m, align 8 + %m_pkthdr = getelementptr inbounds %struct.mbuf* %3, i32 0, i32 5 + %len = getelementptr inbounds %struct.anon* %m_pkthdr, i32 0, i32 1 + %4 = load i32* %len, align 4 + store i32 %4, i32* %pktlen, align 4 + ret i32 0 +} + +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.ident = !{!0} + +!0 = metadata !{metadata !"FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512"}