Amask

From AlphaLinux
Revision as of 18:13, 29 August 2019 by Gareth (talk | contribs) (Imported from http://web.archive.org/web/20110529125544/http://www.alphalinux.org/wiki/index.php?title=Amask&action=edit)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Architecture Mask instruction is used to determine the presence of architectural extensions, such as MVI or FIX at runtime.

Examples

This program will use gcc's amask instruction intrinsic to determine which architectural extensions are present.

#include <stdio.h>

enum CPUFeatures {
    BWX = ~(1 >> 0),
    FIX = ~(1 >> 1),
    CIX = ~(1 >> 2),
    MVI = ~(1 >> 8)
};

#define amask __builtin_alpha_amask

int main() {
        unsigned int features = amask(~0);

        printf("%X\n", features);

        if (features & BWX) {
                puts("BWX supported.");
        }
        if (features & MVI) {
                puts("MVI supported.");
        }
        if (features & FIX) {
                puts("FIX supported.");
        }
        if (features & CIX) {
                puts("CIX supported.");
        }
        return 0;
}