diff --git a/pmu/evt.cpp b/pmu/evt.cpp index e401c7ccdcb9b419e98ef27310a63cdaefdb0817..c9a27ae6e741d56c95b2fe35a9e9aa1eab04c55f 100644 --- a/pmu/evt.cpp +++ b/pmu/evt.cpp @@ -150,11 +150,12 @@ __u32 KUNPENG_PMU::ReadOnce(__u32 *head) typeof(*head) val; char charHead[1]; } pointerUnion = {.charHead = {0}}; - +#if defined(IS_ARM) asm volatile("ldar %w0, %1" : "=r"(*(__u32 __attribute__((__may_alias__)) *)pointerUnion.charHead) : "Q"(*head) : "memory"); +#endif return pointerUnion.val; } @@ -164,11 +165,12 @@ __u16 KUNPENG_PMU::ReadOnce(__u16 *head) typeof(*head) val; char charHead[1]; } pointerUnion = {.charHead = {0}}; - +#if defined(IS_ARM) asm volatile("ldarh %w0, %1" : "=r"(*(__u16 __attribute__((__may_alias__)) *)pointerUnion.charHead) : "Q"(*head) : "memory"); +#endif return pointerUnion.val; } @@ -178,10 +180,11 @@ __u8 KUNPENG_PMU::ReadOnce(__u8 *head) typeof(*head) val; char charHead[1]; } pointerUnion = {.charHead = {0}}; - +#if defined(IS_ARM) asm volatile("ldarb %w0, %1" : "=r"(*(__u8 __attribute__((__may_alias__)) *)pointerUnion.charHead) : "Q"(*head) : "memory"); +#endif return pointerUnion.val; } diff --git a/util/read_reg.cpp b/util/read_reg.cpp index abf550c57975218c25287ee9ed7e3d4e584c8d1c..b43986df8afbeeec45a0b1e4c738878e3931cb01 100644 --- a/util/read_reg.cpp +++ b/util/read_reg.cpp @@ -16,14 +16,17 @@ uint64_t ReadPmccntr() { - uint64_t val; + uint64_t val = 0; +#if defined(__aarch64__) asm volatile("mrs %0, pmccntr_el0" : "=r"(val)); +#endif return val; } uint64_t ReadPmevcntr(int idx) { uint64_t val = 0; +#if defined(__aarch64__) switch (idx) { case 0: asm volatile("mrs %0, pmevcntr0_el0" : "=r"(val)); @@ -121,7 +124,7 @@ uint64_t ReadPmevcntr(int idx) default: break; } - +#endif return val; } @@ -139,7 +142,9 @@ uint64_t ReadPerfCounter(int idx) uint64_t ReadCntvct() { - uint64_t val; + uint64_t val = 0; +#if defined(__aarch64__) asm volatile("mrs %0, cntvct_el0" : "=r"(val)); +#endif return val; } \ No newline at end of file diff --git a/util/read_reg.h b/util/read_reg.h index 87de108aaa478e2c658831c3ed9b015e5dec650a..fd501813b9d4855fe58efe75acb6cfd76c3fba71 100644 --- a/util/read_reg.h +++ b/util/read_reg.h @@ -32,7 +32,9 @@ static uint64_t ReadTimestamp(void) #ifndef Barrier static inline void Barrier() { +#if defined(IS_ARM) asm volatile("" : : : "memory"); +#endif } #endif