mewmew / uc

A compiler for the µC language.
57 stars 5 forks source link

Implicit conversion #63

Closed mewmew closed 8 years ago

mewmew commented 8 years ago
#include <stdio.h>

int main(void) {
    char a = 126;
    char b = 126;
    int c = a + b;
    printf("%d\n", c);
    return 0;
}
; ModuleID = 'a.ll'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1

; Function Attrs: nounwind uwtable
define i32 @main() {
  %1 = sext i8 126 to i32
  %2 = sext i8 126 to i32
  %3 = add nsw i32 %1, %2
  %4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %3)
  ret i32 0
}

declare i32 @printf(i8*, ...)
mewmew commented 8 years ago

We may want to evaluate if we want to make use of wrap flags (e.g. nsw) and take a look at what the default behaviour (without flags) look like.

mewmew commented 8 years ago

Duplicate of #69. Closing