brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · c4149ff Raw
104 lines · plain
1; RUN: llc < %s -mtriple=avr -mcpu=atmega328p | FileCheck %s2 3; This test checks a basic 'blinking led' program.4; It is written for the ATmega328P5 6; Derived from the following C program (with some cleanups):7; #include <avr/io.h>8;9; void setup_ddr() {10;   DDRB |= _BV(PB5);11; }12;13; void turn_on() {14;   PORTB |= _BV(PB5);15; }16;17; void turn_off() {18;   PORTB &= ~_BV(PB5);19; }20;21; int main() {22;   setup_ddr();23;24;   while(1) {25;     turn_on();26;     turn_off();27;   }28;29;   return 0;30; }31 32; Sets up the data direction register.33; CHECK-LABEL: setup_ddr34define void @setup_ddr() {35entry:36 37  ; This should set the 5th bit of DDRB.38  ; CHECK:      sbi	4, 539  ; CHECK-NEXT: ret40 41  %0 = load volatile i8, ptr inttoptr (i16 36 to ptr), align 142  %conv = zext i8 %0 to i1643  %or = or i16 %conv, 3244  %conv1 = trunc i16 %or to i845  store volatile i8 %conv1, ptr inttoptr (i16 36 to ptr), align 146  ret void47}48 49; Turns on the LED.50; CHECK-LABEL: turn_on51define void @turn_on() {52entry:53 54  ; This should set the 5th bit of PORTB55  ; CHECK:      sbi	5, 556  ; CHECK-NEXT: ret57 58  %0 = load volatile i8, ptr inttoptr (i16 37 to ptr), align 159  %conv = zext i8 %0 to i1660  %or = or i16 %conv, 3261  %conv1 = trunc i16 %or to i862  store volatile i8 %conv1, ptr inttoptr (i16 37 to ptr), align 163  ret void64}65 66; Turns off the LED.67; CHECK-LABEL: turn_off68define void @turn_off() {69entry:70 71  ; This should clear the 5th bit of PORTB72  ; CHECK:      cbi     5, 573  ; CHECK-NEXT: ret74 75  %0 = load volatile i8, ptr inttoptr (i16 37 to ptr), align 176  %conv = zext i8 %0 to i1677  %and = and i16 %conv, -3378  %conv1 = trunc i16 %and to i879  store volatile i8 %conv1, ptr inttoptr (i16 37 to ptr), align 180  ret void81}82 83; CHECK-LABEL: main84define i16 @main() {85entry:86 87  ; CHECK: call setup_ddr88  call void @setup_ddr()89 90  br label %while.body91 92; CHECK-LABEL: .LBB3_193while.body:94 95  ; CHECK: call turn_on96  call void @turn_on()97 98  ; CHECK-NEXT: call turn_off99  call void @turn_off()100 101  ; CHECK-NEXT: rjmp .LBB3_1102  br label %while.body103}104