From owner-svn-soc-all@FreeBSD.ORG Tue Aug 12 14:00:37 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 75E8F9A6 for ; Tue, 12 Aug 2014 14:00:37 +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 605C02483 for ; Tue, 12 Aug 2014 14:00:37 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7CE0bso090624 for ; Tue, 12 Aug 2014 14:00:37 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s7CE0a57090605 for svn-soc-all@FreeBSD.org; Tue, 12 Aug 2014 14:00:36 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 12 Aug 2014 14:00:36 GMT Message-Id: <201408121400.s7CE0a57090605@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: r272288 - 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 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 14:00:37 -0000 Author: dpl Date: Tue Aug 12 14:00:35 2014 New Revision: 272288 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272288 Log: Created a dir with llvm examples to be taken for compiling. Added: soc2014/dpl/llvm_examples/ soc2014/dpl/llvm_examples/general.c soc2014/dpl/llvm_examples/general.ll soc2014/dpl/llvm_examples/structs.c Added: soc2014/dpl/llvm_examples/general.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2014/dpl/llvm_examples/general.c Tue Aug 12 14:00:35 2014 (r272288) @@ -0,0 +1,37 @@ +#include +#include +#include + +int +addone(int n) +{ + return (n+1); +} + +int +main(int argc, char *argv[]) +{ + int num; + + if (argc != 2) + err(1, "Usage: %s number", argv[0]); + + if (addone(1) != 2) + printf("what!"); + + num = atoi(argv[1]); + + switch (num) { + case 42: + case 1: + num = addone(num); + break; + case 10: + printf("Ten!\n"); + break; + default: + printf("Waaaat\n"); + } + + return (num); +} Added: soc2014/dpl/llvm_examples/general.ll ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2014/dpl/llvm_examples/general.ll Tue Aug 12 14:00:35 2014 (r272288) @@ -0,0 +1,96 @@ +; ModuleID = 'test.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" + +@.str = private unnamed_addr constant [17 x i8] c"Usage: %s number\00", align 1 +@.str1 = private unnamed_addr constant [6 x i8] c"what!\00", align 1 +@.str2 = private unnamed_addr constant [6 x i8] c"Ten!\0A\00", align 1 +@.str3 = private unnamed_addr constant [8 x i8] c"Waaaat\0A\00", align 1 + +; Function Attrs: nounwind uwtable +define i32 @addone(i32 %n) #0 { +entry: + %n.addr = alloca i32, align 4 + store i32 %n, i32* %n.addr, align 4 + %0 = load i32* %n.addr, align 4 + %add = add nsw i32 %0, 1 + ret i32 %add +} + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** %argv) #0 { +entry: + %retval = alloca i32, align 4 + %argc.addr = alloca i32, align 4 + %argv.addr = alloca i8**, align 8 + %num = alloca i32, align 4 + store i32 0, i32* %retval + store i32 %argc, i32* %argc.addr, align 4 + store i8** %argv, i8*** %argv.addr, align 8 + %0 = load i32* %argc.addr, align 4 + %cmp = icmp ne i32 %0, 2 + br i1 %cmp, label %if.then, label %if.end + +if.then: ; preds = %entry + %1 = load i8*** %argv.addr, align 8 + %arrayidx = getelementptr inbounds i8** %1, i64 0 + %2 = load i8** %arrayidx, align 8 + call void (i32, i8*, ...)* @err(i32 1, i8* getelementptr inbounds ([17 x i8]* @.str, i32 0, i32 0), i8* %2) #3 + unreachable + +if.end: ; preds = %entry + %call = call i32 @addone(i32 1) + %cmp1 = icmp ne i32 %call, 2 + br i1 %cmp1, label %if.then2, label %if.end4 + +if.then2: ; preds = %if.end + %call3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str1, i32 0, i32 0)) + br label %if.end4 + +if.end4: ; preds = %if.then2, %if.end + %3 = load i8*** %argv.addr, align 8 + %arrayidx5 = getelementptr inbounds i8** %3, i64 1 + %4 = load i8** %arrayidx5, align 8 + %call6 = call i32 @atoi(i8* %4) + store i32 %call6, i32* %num, align 4 + %5 = load i32* %num, align 4 + switch i32 %5, label %sw.default [ + i32 42, label %sw.bb + i32 1, label %sw.bb + i32 10, label %sw.bb8 + ] + +sw.bb: ; preds = %if.end4, %if.end4 + %6 = load i32* %num, align 4 + %call7 = call i32 @addone(i32 %6) + store i32 %call7, i32* %num, align 4 + br label %sw.epilog + +sw.bb8: ; preds = %if.end4 + %call9 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str2, i32 0, i32 0)) + br label %sw.epilog + +sw.default: ; preds = %if.end4 + %call10 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([8 x i8]* @.str3, i32 0, i32 0)) + br label %sw.epilog + +sw.epilog: ; preds = %sw.default, %sw.bb8, %sw.bb + %7 = load i32* %num, align 4 + ret i32 %7 +} + +; Function Attrs: noreturn +declare void @err(i32, i8*, ...) #1 + +declare i32 @printf(i8*, ...) #2 + +declare i32 @atoi(i8*) #2 + +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" } +attributes #1 = { noreturn "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" } +attributes #2 = { "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" } +attributes #3 = { noreturn } + +!llvm.ident = !{!0} + +!0 = metadata !{metadata !"FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512"} Added: soc2014/dpl/llvm_examples/structs.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2014/dpl/llvm_examples/structs.c Tue Aug 12 14:00:35 2014 (r272288) @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +#include + +struct mbuf gmbuf; + +int +main() +{ + struct mbuf *m; + int pktlen; + struct ip *ip = mtod(m, struct ip *); + + m = &gmbuf; + pktlen = m->pkthdr.len; + + return (0); +}