Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------hello.c-------------------------
- #include <stdio.h>
- int main() {
- printf("hello world\n");
- return 0;
- }
- int testa() {
- int a = 2 ;
- return a;
- }
- int test() {
- int a = 0;
- a = testa;
- return a;
- }
- int testb() {
- return testa;
- }
- --------------------------
- llvm-gcc-4.2 -O3 -emit-llvm hello.c -c -o hello.bc
- llvm-dis < hello.bc > hello.bc.through_llvm-dis
- -----------------------hello.bc
- ; ModuleID = '<stdin>'
- target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
- target triple = "i386-linux-gnu"
- @.str = private constant [12 x i8] c"hello world\00", align 1
- define i32 @testa() nounwind readnone {
- entry:
- ret i32 2
- }
- define i32 @test() nounwind readnone {
- entry:
- ret i32 ptrtoint (i32 ()* @testa to i32)
- }
- define i32 @testb() nounwind readnone {
- entry:
- ret i32 ptrtoint (i32 ()* @testa to i32)
- }
- define i32 @main() nounwind {
- entry:
- %0 = tail call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i32 0, i32 0)) nounwind
- ret i32 0
- }
- declare i32 @puts(i8* nocapture) nounwind
- -------------------------------------------------
- llc hello.bc -march=c -o hello-llc.c
- --------------------------------------hello-llc.c
- /* Provide Declarations */
- #include <stdarg.h>
- #include <setjmp.h>
- #ifndef __GNUC__ /* Can only support "linkonce" vars with GCC */
- #define __attribute__(X)
- #endif
- #if defined(__GNUC__) && defined(__APPLE_CC__)
- #define __EXTERNAL_WEAK__ __attribute__((weak_import))
- #elif defined(__GNUC__)
- #define __EXTERNAL_WEAK__ __attribute__((weak))
- #else
- #define __EXTERNAL_WEAK__
- #endif
- #if defined(__GNUC__) && defined(__APPLE_CC__)
- #define __ATTRIBUTE_WEAK__
- #elif defined(__GNUC__)
- #define __ATTRIBUTE_WEAK__ __attribute__((weak))
- #else
- #define __ATTRIBUTE_WEAK__
- #endif
- #if defined(__GNUC__)
- #define __HIDDEN__ __attribute__((visibility("hidden")))
- #endif
- #ifdef __GNUC__
- #define LLVM_NAN(NanStr) __builtin_nan(NanStr) /* Double */
- #define LLVM_NANF(NanStr) __builtin_nanf(NanStr) /* Float */
- #define LLVM_NANS(NanStr) __builtin_nans(NanStr) /* Double */
- #define LLVM_NANSF(NanStr) __builtin_nansf(NanStr) /* Float */
- #define LLVM_INF __builtin_inf() /* Double */
- #define LLVM_INFF __builtin_inff() /* Float */
- #define LLVM_PREFETCH(addr,rw,locality) __builtin_prefetch(addr,rw,locality)
- #define __ATTRIBUTE_CTOR__ __attribute__((constructor))
- #define __ATTRIBUTE_DTOR__ __attribute__((destructor))
- #define LLVM_ASM __asm__
- #else
- #define LLVM_NAN(NanStr) ((double)0.0) /* Double */
- #define LLVM_NANF(NanStr) 0.0F /* Float */
- #define LLVM_NANS(NanStr) ((double)0.0) /* Double */
- #define LLVM_NANSF(NanStr) 0.0F /* Float */
- #define LLVM_INF ((double)0.0) /* Double */
- #define LLVM_INFF 0.0F /* Float */
- #define LLVM_PREFETCH(addr,rw,locality) /* PREFETCH */
- #define __ATTRIBUTE_CTOR__
- #define __ATTRIBUTE_DTOR__
- #define LLVM_ASM(X)
- #endif
- #if __GNUC__ < 4 /* Old GCC's, or compilers not GCC */
- #define __builtin_stack_save() 0 /* not implemented */
- #define __builtin_stack_restore(X) /* noop */
- #endif
- #if __GNUC__ && __LP64__ /* 128-bit integer types */
- typedef int __attribute__((mode(TI))) llvmInt128;
- typedef unsigned __attribute__((mode(TI))) llvmUInt128;
- #endif
- #define CODE_FOR_MAIN() /* Any target-specific code for main()*/
- #ifndef __cplusplus
- typedef unsigned char bool;
- #endif
- /* Support for floating point constants */
- typedef unsigned long long ConstantDoubleTy;
- typedef unsigned int ConstantFloatTy;
- typedef struct { unsigned long long f1; unsigned short f2; unsigned short pad[3]; } ConstantFP80Ty;
- typedef struct { unsigned long long f1; unsigned long long f2; } ConstantFP128Ty;
- /* Global Declarations */
- /* Helper union for bitcasts */
- typedef union {
- unsigned int Int32;
- unsigned long long Int64;
- float Float;
- double Double;
- } llvmBitCastUnion;
- /* Structure forward decls */
- struct l_unnamed0;
- /* Typedefs */
- typedef struct l_unnamed0 l_unnamed0;
- /* Structure contents */
- struct l_unnamed0 { unsigned char array[12]; };
- /* External Global Variable Declarations */
- /* Function Declarations */
- unsigned int testa(void);
- unsigned int test(void);
- unsigned int testb(void);
- unsigned int main(void);
- //unsigned int puts(unsigned char *);
- void abort(void);
- /* Global Variable Declarations */
- static struct l_unnamed0 _OC_str;
- /* Global Variable Definitions and Initialization */
- static struct l_unnamed0 _OC_str = { "hello world" };
- /* Function Bodies */
- unsigned int testa(void) {
- return 2u;
- }
- unsigned int test(void) {
- return ((unsigned int )(unsigned long)testa);
- }
- unsigned int testb(void) {
- return ((unsigned int )(unsigned long)testa);
- }
- unsigned int main(void) {
- unsigned int llvm_cbe_tmp__1;
- CODE_FOR_MAIN();
- //llvm_cbe_tmp__1 = /*tail*/ puts(((&_OC_str.array[((signed int )0u)])));
- return 0u;
- }
- -------------------------------------------------------
- sdcc -p18f4455 -L /home/j/local/sdcc/share/sdcc/non-free/lib/pic16/ hello-llc.c
- ---------------------------------------------hello-llc.lst
- gplink-0.13.7 beta
- Copyright (c) 1998-2005 gputils project
- Listing File Generated: 2-13-2011 05:38:58
- Address Value Disassembly Source
- ------- ----- ----------- ------
- ;--------------------------------------------------------
- ; File Created by SDCC : free open source ANSI-C Compiler
- ; Version 3.0.1 #6214 (Feb 7 2011) (Linux)
- ; This file was generated Sun Feb 13 05:38:58 2011
- ;--------------------------------------------------------
- ; PIC16 port for the Microchip 16-bit core micros
- ;--------------------------------------------------------
- list p=18f4455
- radix dec
- ;--------------------------------------------------------
- ; public variables in this module
- ;--------------------------------------------------------
- global _testa
- global _test
- global _testb
- global _main
- ;--------------------------------------------------------
- ; Equates to used internal registers
- ;--------------------------------------------------------
- WREG equ 0xfe8
- FSR1L equ 0xfe1
- FSR2L equ 0xfd9
- POSTDEC1 equ 0xfe5
- PREINC1 equ 0xfe4
- PRODL equ 0xff3
- idata
- __OC_str db 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x00
- ; Internal registers
- .registers udata_ovr 0x0000
- r0x00 res 1
- r0x01 res 1
- r0x02 res 1
- r0x03 res 1
- ;--------------------------------------------------------
- ; interrupt vector
- ;--------------------------------------------------------
- ;--------------------------------------------------------
- ; global & static initialisations
- ;--------------------------------------------------------
- ; I code from now on!
- ; ; Starting pCode block
- S_hello_llc__main code
- _main:
- ; .line 136; hello-llc.c return 0u;
- 000166 6af3 clrf 0xf3, 0 CLRF PRODL
- 000168 6ae8 clrf 0xe8, 0 CLRF WREG
- 00016a 0012 return 0 RETURN
- ; ; Starting pCode block
- S_hello_llc__testb code
- _testb:
- ; .line 126; hello-llc.c unsigned int testb(void) {
- 00009c cfd9 movff 0xfd9, 0xfe5 MOVFF FSR2L, POSTDEC1
- 00009e ffe5
- 0000a0 cfe1 movff 0xfe1, 0xfd9 MOVFF FSR1L, FSR2L
- 0000a2 ffd9
- 0000a4 c000 movff 0, 0xfe5 MOVFF r0x00, POSTDEC1
- 0000a6 ffe5
- 0000a8 c001 movff 0x1, 0xfe5 MOVFF r0x01, POSTDEC1
- 0000aa ffe5
- 0000ac c002 movff 0x2, 0xfe5 MOVFF r0x02, POSTDEC1
- 0000ae ffe5
- 0000b0 c003 movff 0x3, 0xfe5 MOVFF r0x03, POSTDEC1
- 0000b2 ffe5
- ; .line 127; hello-llc.c return ((unsigned int )(unsigned long)testa);
- 0000b4 0e38 movlw 0x38 MOVLW LOW(_testa)
- 0000b6 6e00 movwf 0, 0 MOVWF r0x00
- 0000b8 0e01 movlw 0x1 MOVLW HIGH(_testa)
- 0000ba 6e01 movwf 0x1, 0 MOVWF r0x01
- 0000bc 0e00 movlw 0 MOVLW UPPER(_testa)
- 0000be 6e02 movwf 0x2, 0 MOVWF r0x02
- 0000c0 6a03 clrf 0x3, 0 CLRF r0x03
- 0000c2 c001 movff 0x1, 0xff3 MOVFF r0x01, PRODL
- 0000c4 fff3
- 0000c6 5000 movf 0, 0, 0 MOVF r0x00, W
- 0000c8 cfe4 movff 0xfe4, 0x3 MOVFF PREINC1, r0x03
- 0000ca f003
- 0000cc cfe4 movff 0xfe4, 0x2 MOVFF PREINC1, r0x02
- 0000ce f002
- 0000d0 cfe4 movff 0xfe4, 0x1 MOVFF PREINC1, r0x01
- 0000d2 f001
- 0000d4 cfe4 movff 0xfe4, 0 MOVFF PREINC1, r0x00
- 0000d6 f000
- 0000d8 cfe4 movff 0xfe4, 0xfd9 MOVFF PREINC1, FSR2L
- 0000da ffd9
- 0000dc 0012 return 0 RETURN
- ; ; Starting pCode block
- S_hello_llc__test code
- _test:
- ; .line 121; hello-llc.c unsigned int test(void) {
- 0000de cfd9 movff 0xfd9, 0xfe5 MOVFF FSR2L, POSTDEC1
- 0000e0 ffe5
- 0000e2 cfe1 movff 0xfe1, 0xfd9 MOVFF FSR1L, FSR2L
- 0000e4 ffd9
- 0000e6 c000 movff 0, 0xfe5 MOVFF r0x00, POSTDEC1
- 0000e8 ffe5
- 0000ea c001 movff 0x1, 0xfe5 MOVFF r0x01, POSTDEC1
- 0000ec ffe5
- 0000ee c002 movff 0x2, 0xfe5 MOVFF r0x02, POSTDEC1
- 0000f0 ffe5
- 0000f2 c003 movff 0x3, 0xfe5 MOVFF r0x03, POSTDEC1
- 0000f4 ffe5
- ; .line 122; hello-llc.c return ((unsigned int )(unsigned long)testa);
- 0000f6 0e38 movlw 0x38 MOVLW LOW(_testa)
- 0000f8 6e00 movwf 0, 0 MOVWF r0x00
- 0000fa 0e01 movlw 0x1 MOVLW HIGH(_testa)
- 0000fc 6e01 movwf 0x1, 0 MOVWF r0x01
- 0000fe 0e00 movlw 0 MOVLW UPPER(_testa)
- 000100 6e02 movwf 0x2, 0 MOVWF r0x02
- 000102 6a03 clrf 0x3, 0 CLRF r0x03
- 000104 c001 movff 0x1, 0xff3 MOVFF r0x01, PRODL
- 000106 fff3
- 000108 5000 movf 0, 0, 0 MOVF r0x00, W
- 00010a cfe4 movff 0xfe4, 0x3 MOVFF PREINC1, r0x03
- 00010c f003
- 00010e cfe4 movff 0xfe4, 0x2 MOVFF PREINC1, r0x02
- 000110 f002
- 000112 cfe4 movff 0xfe4, 0x1 MOVFF PREINC1, r0x01
- 000114 f001
- 000116 cfe4 movff 0xfe4, 0 MOVFF PREINC1, r0x00
- 000118 f000
- 00011a cfe4 movff 0xfe4, 0xfd9 MOVFF PREINC1, FSR2L
- 00011c ffd9
- 00011e 0012 return 0 RETURN
- ; ; Starting pCode block
- S_hello_llc__testa code
- _testa:
- ; .line 116; hello-llc.c unsigned int testa(void) {
- 000138 cfd9 movff 0xfd9, 0xfe5 MOVFF FSR2L, POSTDEC1
- 00013a ffe5
- 00013c cfe1 movff 0xfe1, 0xfd9 MOVFF FSR1L, FSR2L
- 00013e ffd9
- ; .line 117; hello-llc.c return 2u;
- 000140 6af3 clrf 0xf3, 0 CLRF PRODL
- 000142 0e02 movlw 0x2 MOVLW 0x02
- 000144 cfe4 movff 0xfe4, 0xfd9 MOVFF PREINC1, FSR2L
- 000146 ffd9
- 000148 0012 return 0 RETURN
- ; Statistics:
- ; code size: 156 (0x009c) bytes ( 0.12%)
- ; 78 (0x004e) words
- ; udata size: 0 (0x0000) bytes ( 0.00%)
- ; access size: 4 (0x0004) bytes
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement