// Get the opcode of an SDValue SDValue value = ... // initialize value unsigned opcode = value.getOpcode(); if (opcode == ISD::ADD) { // do something }
// Get the opcode of an SDNode SDNode* node = ... // initialize node unsigned opcode = node->getOpcode(); if (opcode == ISD::LOAD) { // do something }In this example, we get the opcode of an SDNode by calling the getOpcode() function on the pointer to the node. We then check if the opcode is equal to ISD::LOAD (the enum value for the load operation), and perform some action if it is. This code also belongs to the LLVM package library.