1/* 2 * Copyright 2019, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the GNU General Public License version 2. Note that NO WARRANTY is provided. 8 * See "LICENSE_GPLv2.txt" for details. 9 * 10 * @TAG(DATA61_GPL) 11 */ 12 13 14/* 15#define ALIGN(x,a) ((x) % (a) ? (x) + (a) - ((x) % (a)) : (x)) 16 17$ty:(U32) align32($ty:((U32, U32)) args) 18{ 19 return ALIGN(args.p1, args.p2); 20} 21 22$ty:(U64) align64($ty:((U64, U64)) args) 23{ 24 return ALIGN(args.p1, args.p2); 25} 26*/ 27 28//u8_to_u16: U8 -> U16 29$ty:(U16) u8_to_u16($ty:(U8) x) { 30 return ($ty:(U16))x; 31} 32 33//u8_to_u32: U8 -> U32 34$ty:(U32) u8_to_u32($ty:(U8) x) { 35 return ($ty:(U32))x; 36} 37 38//u8_to_u64: U8 -> U64 39$ty:(U64) u8_to_u64($ty:(U8) x) { 40 return ($ty:(U64))x; 41} 42 43//u16_to_u8: U16 -> U8 44$ty:(U8) u16_to_u8($ty:(U16) x) { 45 return ($ty:(U8))x; 46} 47 48//u16_to_u32: U16 -> U32 49$ty:(U32) u16_to_u32($ty:(U16) x) { 50 return ($ty:(U32))x; 51} 52 53//u32_to_u8: U32 -> U8 54$ty:(U8) u32_to_u8($ty:(U32) x) { 55 return ($ty:(U8))x; 56} 57 58//u32_to_u16: U32 -> U16 59$ty:(U16) u32_to_u16($ty:(U32) x) { 60 return ($ty:(U16))x; 61} 62 63//u32_to_u64: U32 -> U64 64$ty:(U64) u32_to_u64($ty:(U32) x) { 65 return ($ty:(U64))x; 66} 67 68//u64_to_u32: U64 -> U32 69$ty:(U32) u64_to_u32($ty:(U64) x) { 70 return ($ty:(U32))x; 71} 72 73$ty:(U8) u64_to_u8($ty:(U64) x) 74{ 75 return ($ty:(U8))x; 76} 77 78$ty:(U16) u64_to_u16($ty:(U64) x) 79{ 80 return ($ty:(U16))x; 81} 82